From 850ab3eb4679adf93b59f8bd3ea9e3e6a3d9d36a Mon Sep 17 00:00:00 2001 From: Franco Reyes Date: Wed, 27 Mar 2024 14:25:20 +1100 Subject: [PATCH] Add CD --- .github/workflows/docker.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ce2d96d..cf147d1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -52,3 +52,32 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + deploy: + name: Deploy (CD) + runs-on: ubuntu-latest + needs: [ build ] + if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }} + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + with: + repository: csesoc/deployment + ref: migration + token: ${{ secrets.GH_TOKEN }} + - name: Install yq + uses: mikefarah/yq@v4.40.5 + - name: Update deployment + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + git config user.name "CSESoc CD" + git config user.email "technical@csesoc.org.au" + + git checkout -b update/nss-scraper/${{ github.sha }} + yq -i '.spec.jobTemplate.spec.template.spec.containers[0].image = "ghcr.io/devsoc-unsw/nss-scraper:${{ github.sha }}"' projects/timetable-scraper/cronjob.yml + + git add . + git commit -m "feat(nss-scraper): update image" + git push -u origin update/nss-scraper/${{ github.sha }} + gh pr create -B migration --title "feat(nss-scraper): update image" --body "Updates the image for the nss-scraper deployment to commit devsoc-unsw/nss-scraper@${{ github.sha }}." > URL + gh pr merge $(cat URL) --squash -d \ No newline at end of file