Skip to content

chore(ci): add workflow for deploying built images #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Docker
on:
push:
branches: [ "master" ]

jobs:
build:
name: "Build (${{ matrix.component }})"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
component: [frontend, backend]
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@v3
with:
context: ${{ matrix.component }}
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64
file: ${{ matrix.component }}/Dockerfile
tags: |
ghcr.io/csesoc/subcomp-${{ matrix.component }}:${{ github.sha }}
ghcr.io/csesoc/subcomp-${{ matrix.component }}:latest
labels: ${{ steps.meta.outputs.labels }}
deploy:
name: Deploy (CD)
runs-on: ubuntu-latest
needs: [build]
concurrency: production
environment: production
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}

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/subcomp/${{ github.sha }}
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/subcomp-frontend:${{ github.sha }}"' apps/subcom/competitions/subcomp/deploy-frontend.yml
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/subcomp-backend:${{ github.sha }}"' apps/subcom/competitions/subcomp/deploy-backend.yml
git add .
git commit -m "feat(subcomp): update images"
git push -u origin update/subcomp/${{ github.sha }}
gh pr create --title "feat(subcomp): update image" --body "Updates the images for the subcomp deployment to commit csesoc/subcomp@${{ github.sha }}." > URL
gh pr merge $(cat URL) --squash -d