Skip to content

feat: flush batches at the top of the hour (#46) #224

feat: flush batches at the top of the hour (#46)

feat: flush batches at the top of the hour (#46) #224

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: Push private image
if: ${{ env.PUBLISH == 'true' }}
run: go run ci/cmd/build/main.go
-
name: Login to public ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
username: ${{ env.AWS_ACCESS_KEY_ID }}
password: ${{ env.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
-
name: Push public image
if: ${{ env.PUBLISH == 'true' }}
run: |
docker buildx build --load -t 3box/go-cas .
docker tag 3box/go-cas:latest public.ecr.aws/r5b3e0r5/3box/go-cas:latest
docker push public.ecr.aws/r5b3e0r5/3box/go-cas:latest
-
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