3
3
push :
4
4
branches :
5
5
- " master"
6
+ - " qa"
6
7
7
8
jobs :
8
9
build :
@@ -34,21 +35,21 @@ jobs:
34
35
uses : docker/build-push-action@v5
35
36
with :
36
37
context : ${{ matrix.component }}
37
- push : ${{ github.event_name != 'pull_request' }}
38
+ push : ${{ github.event_name != 'pull_request' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/qa' ) }}
38
39
platforms : linux/amd64
39
40
file : ${{ matrix.component }}/Dockerfile
40
41
tags : |
41
42
ghcr.io/csesoc/website-${{ matrix.component }}:${{ github.sha }}
42
43
ghcr.io/csesoc/website-${{ matrix.component }}:latest
43
44
labels : ${{ steps.meta.outputs.labels }}
44
- deploy-prod :
45
- name : Deploy Production (CD)
45
+ deploy :
46
+ name : Deploy (CD)
46
47
runs-on : ubuntu-latest
47
48
needs : [build]
48
49
concurrency : prod
49
50
environment :
50
51
name : prod
51
- if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
52
+ if : ${{ github.event_name != 'pull_request' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/qa' ) }}
52
53
steps :
53
54
- name : Checkout repository
54
55
uses : actions/checkout@v4
@@ -58,17 +59,29 @@ jobs:
58
59
ref : develop
59
60
- name : Install yq - portable yaml processor
60
61
uses : mikefarah/yq@v4.27.2
62
+ - name : " Determine deployment type"
63
+ id : get_manifest
64
+ env :
65
+ BRANCH : ${{ github.ref }}
66
+ run : |
67
+ if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
68
+ echo "TYPE=prod" >> $GITHUB_OUTPUT
69
+ elif [[ "${{ github.ref }}" == "refs/heads/qa" ]]; then
70
+ echo "TYPE=qa" >> $GITHUB_OUTPUT
71
+ else
72
+ exit 1
73
+ fi
61
74
- name : Update deployment
62
75
env :
63
76
GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
64
77
run : |
65
78
git config user.name "CSESoc CD"
66
79
git config user.email "technical@csesoc.org.au"
67
- git checkout -b update/website-prod /${{ github.sha }}
68
- yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-backend:${{ github.sha }}"' apps/projects/website/prod /deploy-backend.yml
69
- yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-frontend:${{ github.sha }}"' apps/projects/website/prod /deploy-frontend.yml
80
+ git checkout -b update/website-${{ steps.get_manifest.outputs.TYPE }} /${{ github.sha }}
81
+ yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-backend:${{ github.sha }}"' apps/projects/website/${{ steps.get_manifest.outputs.TYPE }} /deploy-backend.yml
82
+ yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-frontend:${{ github.sha }}"' apps/projects/website/${{ steps.get_manifest.outputs.TYPE }} /deploy-frontend.yml
70
83
git add .
71
- git commit -m "feat(website/prod ): update image"
72
- git push -u origin update/website-prod /${{ github.sha }}
73
- gh pr create -B develop --title "feat(website/prod ): update image" --body "Updates the image for the website-prod deployment to commit csesoc/csesoc-website@${{ github.sha }}." > URL
84
+ git commit -m "feat(website/${{ steps.get_manifest.outputs.TYPE }} ): update image"
85
+ git push -u origin update/website-${{ steps.get_manifest.outputs.TYPE }} /${{ github.sha }}
86
+ gh pr create -B develop --title "feat(website/${{ steps.get_manifest.outputs.TYPE }} ): update image" --body "Updates the image for the website-prod deployment to commit csesoc/csesoc-website@${{ github.sha }}." > URL
74
87
gh pr merge $(cat URL) --squash -d
0 commit comments