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/master' || 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/master' }}
52+ if : ${{ github.event_name != 'pull_request' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/qa' ) }}
5253 steps :
5354 - name : Checkout repository
5455 uses : actions/checkout@v4
@@ -58,17 +59,29 @@ jobs:
5859 ref : develop
5960 - name : Install yq - portable yaml processor
606162+ - 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
6174 - name : Update deployment
6275 env :
6376 GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
6477 run : |
6578 git config user.name "CSESoc CD"
6679 git config user.email "[email protected] " 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
7083 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
7487 gh pr merge $(cat URL) --squash -d
0 commit comments