Deploy #141
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: Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment to deploy to' | |
required: true | |
default: 'production' | |
ref: | |
description: 'Git reference to deploy' | |
required: false | |
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: ${{ github.event_name != 'pull_request' }} | |
platforms: linux/amd64 | |
file: ${{ matrix.component }}/Dockerfile.prod | |
tags: | | |
ghcr.io/csesoc/structs-${{ matrix.component }}:${{ github.sha }} | |
ghcr.io/csesoc/structs-${{ matrix.component }}:latest | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy: | |
name: Deploy (CD) | |
runs-on: ubuntu-latest | |
needs: [build] | |
concurrency: production | |
environment: production | |
env: | |
VITE_DEBUGGER_URL: ${{ secrets.DEBUGGER_URL }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
repository: csesoc/deployment | |
token: ${{ secrets.GH_TOKEN }} | |
ref: migration | |
- name: Install yq | |
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/structs/${{ github.sha }} | |
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/structs-client:${{ github.sha }}"' projects/structs/deploy-frontend.yml | |
git add . | |
git commit -m "feat(structs): update image" | |
git push -u origin update/structs/${{ github.sha }} | |
gh pr create -B migration --title "feat(structs): update image" --body "Updates the image for the structs deployment to commit csesoc/structs.sh@${{ github.sha }}." > URL | |
gh pr merge $(cat URL) --squash -d |