Skip to content

Promotional banner (#1025) #704

Promotional banner (#1025)

Promotional banner (#1025) #704

Workflow file for this run

name: Docker
on:
push:
branches:
- dev
- staging
env:
ENVIRONMENT: ${{ github.ref_name == 'dev' && 'prod' || 'staging' }}
IMAGE_NAME: ${{ github.ref_name == 'dev' && 'notangles' || 'notangles-staging' }}
jobs:
build-client:
name: 'Build (Client)'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
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: |
FACEBOOK_APP_ID=${{ secrets.FACEBOOK_APP_ID }}
GOOGLE_ANALYTICS_ID=${{ secrets.GOOGLE_ANALYTICS_ID }}
GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }}
GOOGLE_OAUTH_CLIENT_ID=${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}
SENTRY_INGEST_CLIENT=${{ secrets.SENTRY_INGEST_CLIENT }}
SENTRY_TRACE_RATE_CLIENT=${{ secrets.SENTRY_TRACE_RATE_CLIENT }}
GIT_COMMIT=${{ github.sha }}
tags: |
ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-client:${{ github.sha }}
ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-client:latest
labels: ${{ steps.meta.outputs.labels }}
build:
name: 'Build (${{ matrix.component }})'
runs-on: ubuntu-latest
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
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.component }}
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
labels: ${{ steps.meta.outputs.labels }}
deploy:
name: Deploy (CD)
runs-on: ubuntu-latest
needs: [build-client, build]
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
concurrency: production
environment: production
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: devsoc-unsw/deployment
token: ${{ secrets.GH_TOKEN }}
ref: dev
- name: Install yq - portable yaml processor
uses: mikefarah/[email protected]
- name: Update deployment
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git config user.name "CSESoc CD"
git config user.email "[email protected]"
git checkout -b update/${{ env.IMAGE_NAME }}/${{ github.sha }}
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-client:${{ github.sha }}"' projects/notangles/${{ env.ENVIRONMENT }}/deploy-frontend.yml
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-backend:${{ github.sha }}"' projects/notangles/${{ env.ENVIRONMENT }}/deploy-backend.yml
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/devsoc-unsw/${{ env.IMAGE_NAME }}-auto-timetabler-server:${{ github.sha }}"' projects/notangles/${{ env.ENVIRONMENT }}/deploy-auto-timetabler.yml
git add .
git commit -m "feat(${{ env.IMAGE_NAME }}): update images"
git push -u origin update/${{ env.IMAGE_NAME }}/${{ github.sha }}
gh pr create -B dev --title "feat(${{ env.IMAGE_NAME }}): update images" --body "Updates the images for the ${{ env.IMAGE_NAME }} deployment to commit devsoc-unsw/${{ env.IMAGE_NAME }}@${{ github.sha }}." > URL
gh pr merge $(cat URL) --squash -d