-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Container registry github action first draft
- Loading branch information
1 parent
3acf12c
commit 892efc3
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Docker | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
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@v5 | ||
with: | ||
context: client | ||
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | ||
platforms: linux/amd64 | ||
file: client/Dockerfile | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
build-args: | | ||
HASURAGRES_API_KEY=${{ secrets.HASURAGRES_API_KEY }} | ||
HASURAGRES_URL=${{ secrets.HASURAGRES_URL }} | ||
tags: | | ||
ghcr.io/csesoc/spooderman:${{ github.sha }} | ||
ghcr.io/csesoc/spooderman: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/main' }} | ||
concurrency: production | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: csesoc/deployment | ||
token: ${{ secrets.GH_TOKEN }} | ||
ref: migration | ||
- 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/spooderman/${{ github.sha }} | ||
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/spooderman:${{ github.sha }}"' projects/spooderman/cronjob.yml | ||
git add . | ||
git commit -m "feat(spooderman): update images" | ||
git push -u origin update/spooderman/${{ github.sha }} | ||
gh pr create -B migration --title "feat(spooderman): update images" --body "Updates the images for the spooderman timetable scraper deployment to commit csesoc/spooderman@${{ github.sha }}." > URL | ||
gh pr merge $(cat URL) --squash -d |