Skip to content

merged master

merged master #1561

Workflow file for this run

name: Docker
on:
push:
jobs:
build:
name: "Build (${{ matrix.component }})"
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
component: [backend, frontend, next, postgres]
include:
- component: backend
name: cms-backend
- component: frontend
name: cms-frontend
- component: next
name: website-frontend
- component: postgres
name: cms-migrations
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- 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: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
platforms: linux/amd64
file: ${{ matrix.component }}/Dockerfile
tags: |
ghcr.io/csesoc/${{ matrix.name }}:${{ github.sha }}
ghcr.io/csesoc/${{ matrix.name }}:latest
labels: ${{ steps.meta.outputs.labels }}
deploy:
name: Deploy (CD)
runs-on: ubuntu-latest
needs: [build]
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
concurrency: staging
environment:
name: staging
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: csesoc/deployment
token: ${{ secrets.GH_TOKEN }}
- 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/cms/${{ github.sha }}
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/cms-frontend:${{ github.sha }}"' apps/projects/cms/staging/deploy-cms-frontend.yml
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/cms-backend:${{ github.sha }}"' apps/projects/cms/staging/deploy-cms-backend.yml
yq -i '.items[0].spec.template.spec.initContainers[0].image = "ghcr.io/csesoc/cms-migrations:${{ github.sha }}"' apps/projects/cms/staging/deploy-cms-backend.yml
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-frontend:${{ github.sha }}"' apps/projects/cms/staging/deploy-website-frontend.yml
git add .
git commit -m "feat(cms/staging): update images"
git push -u origin update/cms/${{ github.sha }}
gh pr create --title "feat(cms/staging): update images" --body "Updates the images for the cms deployment to commit csesoc/cms.csesoc.unsw.edu.au@${{ github.sha }}." > URL
gh pr merge $(cat URL) --squash -d