Skip to content

Merge pull request #768 from devsoc-unsw/fix-docker-environment #168

Merge pull request #768 from devsoc-unsw/fix-docker-environment

Merge pull request #768 from devsoc-unsw/fix-docker-environment #168

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
push:
branches:
- main
- staging
env:
ENVIRONMENT: ${{ github.ref_name == 'main' && 'prod' || 'staging' }}
IMAGE_NAME: ${{ format('devsoc-unsw/structs{0}', github.ref_name == 'main' && '' || '-staging') }}
jobs:
build:
name: "Build (${{ matrix.component }})"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
component: [client, debugger]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ${{ matrix.component }}
push: true
platforms: linux/amd64
file: ${{ matrix.component }}/Dockerfile.prod
tags: |
ghcr.io/${{ env.IMAGE_NAME }}-${{ matrix.component }}:${{ github.sha }}
ghcr.io/${{ env.IMAGE_NAME }}-${{ matrix.component }}:latest
labels: ${{ steps.meta.outputs.labels }}
build-args: "VITE_DEBUGGER_URL=https://structs.sh"
deploy:
name: Deploy (CD)
runs-on: ubuntu-latest
needs: [build]
concurrency: ${{ github.ref_name == 'main' && 'production' || 'staging' }}
environment: ${{ github.ref_name == 'main' && 'production' || 'staging' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: devsoc-unsw/deployment
token: ${{ secrets.GH_TOKEN }}
ref: dev
- name: Install yq
uses: mikefarah/yq@v4.35.1
- name: Update deployment
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git config user.name "CSESoc CD"
git config user.email "technical@csesoc.org.au"
git checkout -b update/structs/${{ github.sha }}
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/${{ env.IMAGE_NAME }}-client:${{ github.sha }}"' projects/structs/${{ env.ENVIRONMENT }}/deploy-frontend.yml
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/${{ env.IMAGE_NAME }}-debugger:${{ github.sha }}"' projects/structs/${{ env.ENVIRONMENT }}/deploy-debugger.yml
git add .
git commit -m "feat(structs): update image"
git push -u origin update/structs/${{ github.sha }}
gh pr create -B dev --title "feat(structs): update image" --body "Updates the image for the structs deployment to commit devsoc-unsw/structs.sh@${{ github.sha }}." > URL
gh pr merge $(cat URL) --squash -d