Skip to content

Fix proto file

Fix proto file #8

Workflow file for this run

name: TgTime API Deploy
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'
- name: Build
run: go build -v ./...
build-and-push-image:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Add config
run: |
echo ENV="dev" >> ./.env
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./docker/app/Dockerfile
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
migrate:
runs-on: ubuntu-latest
needs: build-and-push-image
environment: migrations
defaults:
run:
working-directory: .
steps:
- name: Checkout
uses: actions/checkout@v3
- name: copy migration files
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: "db/migrations/*"
target: "/opt/tgtime-api/"
- name: migrate
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
migrate -source file:///opt/tgtime-api/db/migrations -database postgres://tgtime_api_user:tgtime_api_password@localhost:5432/tgtime_api?sslmode=disable up
deploy:
runs-on: self-hosted
needs: build-and-push-image
steps:
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run container
run: |
cd /opt/tgtime-api
docker-compose up --build --pull=always &