CI #454
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}} | |
DOCKER_REPO: registry.fly.io | |
APP_NAME: formsg | |
steps: | |
- name: Checkout opengovsg/FormSG into the same local dir | |
uses: actions/checkout@v4 | |
with: | |
repository: opengovsg/FormSG | |
ref: refs/heads/release-al2 | |
- name: Checkout this repo | |
uses: actions/checkout@v4 | |
with: | |
path: demos | |
- name: Move demos contents into local root | |
run: mv demos/* . | |
- name: Replace files with demo-specific ones | |
run: | | |
cp -rf replacements/* . | |
rm -rf replacements | |
- name: Substitute index.html OG params (delivered by Fly's proxy) | |
run: | | |
cat frontend/index.html | \ | |
sed 's/__OG_TITLE__/[DEMO] Form @ demos.sg/' | \ | |
sed 's/__OG_DESCRIPTION__/A demo of FormSG on demos.sg/' | \ | |
sed 's/__OG_IMAGE__/og-img-metatag-publicform.png/' > frontend/index2.html && \ | |
mv frontend/index2.html frontend/index.html | |
- 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@v3 | |
- 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@v5 | |
with: | |
push: true | |
context: . | |
file: ./Dockerfile.demos | |
tags: ${{env.DOCKER_REPO}}/${{env.APP_NAME}}:${{env.APP_VERSION}} | |
- name: Deploy to Fly | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
run: | | |
flyctl deploy --ha=false --image ${{env.DOCKER_REPO}}/${{env.APP_NAME}}:${{env.APP_VERSION}} |