Skip to content

Commit

Permalink
Container registry github action first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinoGoblino authored Sep 22, 2024
1 parent 3acf12c commit 892efc3
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/docker.yml
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

0 comments on commit 892efc3

Please sign in to comment.