Merge pull request #31 from terratensor/develop #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
REGISTRY: ghcr.io/terratensor | |
REGISTRY_HOST: ghcr.io | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Docker Login | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ env.REGISTRY_HOST }} | |
username: audetv | |
password: ${{ github.token }} | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.20.1 | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: go test -v ./... | |
- name: Inject branch slug | |
uses: rlespinasse/[email protected] | |
- name: Set image tag | |
run: echo "::set-env name=IMAGE_TAG::${{ env.GITHUB_REF_SLUG }}-${GITHUB_RUN_NUMBER}" | |
- name: Build | |
run: make docker-build | |
- name: Push build cache images | |
run: make push-build-cache | |
- name: Push | |
run: make push | |
if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.PRODUCTION_KEY }} | |
known_hosts: ${{ secrets.PRODUCTION_HOST }} | |
if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Deploy | |
run: make deploy | |
env: | |
BUILD_NUMBER: ${GITHUB_RUN_NUMBER} | |
HOST: ${{ secrets.PRODUCTION_HOST }} | |
PORT: ${{ secrets.PRODUCTION_PORT }} | |
APP_POSTGRES_HOST: ${{ secrets.APP_POSTGRES_HOST }} | |
APP_POSTGRES_DB: ${{ secrets.APP_POSTGRES_DB }} | |
APP_POSTGRES_USER: ${{ secrets.APP_POSTGRES_USER }} | |
APP_TG_BOT_TOKEN_FILE: ${{ secrets.APP_TG_BOT_TOKEN_FILE }} | |
APP_SENTRY_DSN_FILE: ${{ secrets.APP_SENTRY_DSN_FILE }} | |
APP_DB_PASSWORD_FILE: ${{ secrets.APP_DB_PASSWORD_FILE }} | |
if: ${{ github.ref == 'refs/heads/main' }} |