33 push :
44 branches :
55 - " master"
6+ - " qa"
67
78jobs :
89 build :
@@ -34,21 +35,21 @@ jobs:
3435 uses : docker/build-push-action@v5
3536 with :
3637 context : ${{ matrix.component }}
37- push : ${{ github.event_name != 'pull_request' }}
38+ push : ${{ github.event_name != 'pull_request' && ( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/qa' ) }}
3839 platforms : linux/amd64
3940 file : ${{ matrix.component }}/Dockerfile
4041 tags : |
4142 ghcr.io/csesoc/website-${{ matrix.component }}:${{ github.sha }}
4243 ghcr.io/csesoc/website-${{ matrix.component }}:latest
4344 labels : ${{ steps.meta.outputs.labels }}
44- deploy-prod :
45- name : Deploy Production (CD)
45+ deploy :
46+ name : Deploy (CD)
4647 runs-on : ubuntu-latest
4748 needs : [build]
4849 concurrency : prod
4950 environment :
5051 name : prod
51- if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
52+ if : ${{ github.event_name != 'pull_request' && ( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/qa' ) }}
5253 steps :
5354 - name : Checkout repository
5455 uses : actions/checkout@v4
@@ -58,48 +59,29 @@ jobs:
5859 ref : develop
5960 - name : Install yq - portable yaml processor
6061 uses : mikefarah/yq@v4.27.2
61- - name : Update deployment
62+ - name : " Determine deployment type"
63+ id : get_manifest
6264 env :
63- GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
65+ BRANCH : ${{ github.ref }}
6466 run : |
65- git config user.name "CSESoc CD"
66- 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
70- 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
74- gh pr merge $(cat URL) --squash -d
75- deploy-qa :
76- name : Deploy QA (CD)
77- runs-on : ubuntu-latest
78- needs : [build]
79- concurrency : qa
80- environment :
81- name : qa
82- if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/qa' }}
83- steps :
84- - name : Checkout repository
85- uses : actions/checkout@v4
86- with :
87- repository : csesoc/deployment
88- token : ${{ secrets.GH_TOKEN }}
89- ref : develop
90- - name : Install yq - portable yaml processor
91- uses : mikefarah/yq@v4.27.2
67+ if [[ "${{ github.ref }}" == "refs/heads/main" ]]; 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
9274 - name : Update deployment
9375 env :
9476 GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
9577 run : |
9678 git config user.name "CSESoc CD"
9779 git config user.email "technical@csesoc.org.au"
98- git checkout -b update/website-qa /${{ github.sha }}
99- yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-qa- backend:${{ github.sha }}"' apps/projects/website/qa /deploy-backend.yml
100- yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-qa- frontend:${{ github.sha }}"' apps/projects/website/qa /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
10183 git add .
102- git commit -m "feat(website/qa ): update image"
103- git push -u origin update/website-qa /${{ github.sha }}
104- gh pr create -B develop --title "feat(website/qa ): update image" --body "Updates the image for the website-qa 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
10587 gh pr merge $(cat URL) --squash -d
0 commit comments