Skip to content

chore(deps): update ci-actions (#1106) #728

chore(deps): update ci-actions (#1106)

chore(deps): update ci-actions (#1106) #728

Workflow file for this run

name: Docker
on:
push:
branches:
- dev
- staging
permissions: {}
env:
IMAGE_NAME: ${{ github.ref_name == 'dev' && 'notangles' || 'notangles-staging' }}
jobs:
build-client:
name: 'Build (Client)'
runs-on: ubuntu-latest
concurrency:
group: docker-build-client-${{ github.ref }}
cancel-in-progress: true
timeout-minutes: 30
environment: ${{ github.ref_name == 'dev' && 'Production' || 'staging' }}
permissions:
contents: read
packages: write # Required to publish container tags to GHCR.
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push Docker image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: client
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
platforms: linux/amd64
file: client/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
CLARITY_PROJECT_ID=${{ secrets.CLARITY_PROJECT_ID }}
GIT_COMMIT=${{ github.sha }}
tags: |
ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-client:${{ github.sha }}
ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-client:latest
build:
name: 'Build (${{ matrix.component }})'
runs-on: ubuntu-latest
concurrency:
group: docker-build-${{ matrix.component }}-${{ github.ref }}
cancel-in-progress: true
timeout-minutes: 30
strategy:
fail-fast: true
matrix:
component: [server, auto_server]
include:
- component: server
name: backend
- component: auto_server
name: auto-timetabler-server
permissions:
contents: read
packages: write # Required to publish container tags to GHCR.
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push Docker image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: ${{ matrix.component }} # zizmor: ignore[template-injection] matrix values are hard-coded in this workflow
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
platforms: linux/amd64
file: ${{ matrix.component }}/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-${{ matrix.name }}:${{ github.sha }}
ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-${{ matrix.name }}:latest
repo_dispatch:
name: Notify deployment repo
runs-on: ubuntu-latest
needs: [build-client, build]
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
concurrency:
group: docker-repo-dispatch-${{ github.ref }}
cancel-in-progress: true
timeout-minutes: 10
permissions: {}
environment: production
steps:
- name: Create GitHub App token
id: app-token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
with:
app-id: ${{ vars.IMAGE_UPDATER_APP_ID }}
private-key: ${{ secrets.IMAGE_UPDATER_APP_PRIVATE_KEY }}
owner: devsoc-unsw
repositories: deployment
permission-actions: write
- name: Send workflow_dispatch
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
IMAGE_TAG: ${{ github.sha }}
run: |
updates_json="$(
jq -cn \
--arg sha "${IMAGE_TAG}" \
'[
{image: "ghcr.io/devsoc-unsw/notangles-client", tag: $sha},
{image: "ghcr.io/devsoc-unsw/notangles-backend", tag: $sha},
{image: "ghcr.io/devsoc-unsw/notangles-auto-timetabler-server", tag: $sha}
]'
)"
payload_json="$(
jq -cn \
--arg ref "dev" \
--arg updates "${updates_json}" \
'{ref: $ref, inputs: {updates: $updates}}'
)"
curl --fail-with-body \
-L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
https://api.github.com/repos/devsoc-unsw/deployment/actions/workflows/dispatch-image-update.yml/dispatches \
-d "${payload_json}"