Skip to content

feat: context cleanup and graceful shutdown (#16) #61

feat: context cleanup and graceful shutdown (#16)

feat: context cleanup and graceful shutdown (#16) #61

Workflow file for this run

name: Build and deploy
on:
push:
branches: [ develop, release-candidate, main ]
pull_request: # pull requests
workflow_dispatch: # manually triggered
env:
# Secrets
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
# GitHub
RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
BRANCH: ${{ github.head_ref || github.ref_name }}
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v2
with:
ref: ${{ env.BRANCH }}
-
name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: '>=1.19.0'
-
name: Set sha tag
run: |
SHA=$(git rev-parse HEAD)
SHA_TAG=$(git rev-parse --short=12 HEAD)
echo "SHA=$SHA" >> $GITHUB_ENV
echo "SHA_TAG=$SHA_TAG" >> $GITHUB_ENV
echo "STATUS_URL=https://api.github.com/repos/ceramicnetwork/go-cas/statuses/$SHA" >> $GITHUB_ENV
-
name: Set main branch tag
if: ${{ env.BRANCH == 'main' }}
run: |
echo "ENV_TAG=prod" >> $GITHUB_ENV
-
name: Set rc branch tag
if: ${{ env.BRANCH == 'release-candidate' }}
run: |
echo "ENV_TAG=tnet" >> $GITHUB_ENV
-
name: Set develop branch tag
if: ${{ env.BRANCH == 'develop' || env.ENV_TAG == '' }}
run: |
echo "ENV_TAG=dev" >> $GITHUB_ENV
-
name: Set commit status "pending"
run: go run ci/cmd/status/main.go -s pending
-
name: Run unit tests
run: go run ci/cmd/test/main.go
-
name: Set publish flag
if: ${{ env.BRANCH == 'main' || env.BRANCH == 'release-candidate' || env.BRANCH == 'develop' }}
run: echo "PUBLISH=true" >> $GITHUB_ENV
-
name: Build and push image
if: ${{ env.PUBLISH == 'true' }}
run: go run ci/cmd/build/main.go
-
name: Create deployment job
if: ${{ env.PUBLISH == 'true' }}
run: go run ci/cmd/deploy/main.go
-
name: Set commit status "success"
run: go run ci/cmd/status/main.go -s success
-
name: Set commit status "failure"
if: ${{ failure() }}
run: go run ci/cmd/status/main.go -s failure