build(deploy): make initial CI flow #2
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: CI | |
on: | |
workflow_dispatch: | |
push: | |
pull_request: | |
types: [opened, reopened] | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
- cron: '30 15 * * *' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_TAG: github-actions-${{ github.sha }}-${{ github.run_id }}-${{github.run_attempt}} | |
steps: | |
- name: Checkout this repo | |
uses: actions/checkout@v4 | |
- name: Checkout opengovsg/FormSG | |
uses: actions/checkout@v4 | |
with: | |
repository: opengovsg/FormSG | |
ref: refs/heads/release-al2 | |
- name: Set app version | |
run: | | |
echo "APP_VERSION=$(jq -r .version package.json)-$(echo ${GITHUB_REF##*/})-$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Setup Fly | |
uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Auth to Fly Docker | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
run: flyctl auth docker | |
- name: Build docker image | |
uses: docker/build-push-action@v3 | |
env: | |
DOCKER_REPO: registry.fly.io | |
APP_NAME: FormSG | |
with: | |
context: . | |
file: ./Dockerfile.demos | |
tags: registry.fly.io/${{env.APP_NAME}}:${{env.APP_VERSION}} |