1
+ name : Docker
2
+ on :
3
+ push :
4
+ branches :
5
+ - " master"
6
+
7
+ jobs :
8
+ build :
9
+ name : " Build (${{ matrix.component }})"
10
+ runs-on : ubuntu-latest
11
+ permissions :
12
+ contents : read
13
+ packages : write
14
+ strategy :
15
+ fail-fast : true
16
+ matrix :
17
+ component : [backend, frontend]
18
+ steps :
19
+ - name : Checkout repository
20
+ uses : actions/checkout@v4
21
+ - name : Set up QEMU
22
+ uses : docker/setup-qemu-action@v3
23
+ with :
24
+ platforms : arm64
25
+ - name : Set up Docker Buildx
26
+ uses : docker/setup-buildx-action@v3
27
+ - name : Log into registry ${{ env.REGISTRY }}
28
+ uses : docker/login-action@v3
29
+ with :
30
+ registry : ghcr.io
31
+ username : ${{ github.actor }}
32
+ password : ${{ secrets.GH_TOKEN }}
33
+ - name : Build and push Docker image
34
+ uses : docker/build-push-action@v5
35
+ with :
36
+ context : ${{ matrix.component }}
37
+ push : ${{ github.event_name != 'pull_request' }}
38
+ platforms : linux/amd64
39
+ file : ${{ matrix.component }}/Dockerfile
40
+ tags : |
41
+ ghcr.io/csesoc/website-${{ matrix.component }}:${{ github.sha }}
42
+ ghcr.io/csesoc/website-${{ matrix.component }}:latest
43
+ labels : ${{ steps.meta.outputs.labels }}
44
+ deploy-prod :
45
+ name : Deploy Production (CD)
46
+ runs-on : ubuntu-latest
47
+ needs : [build]
48
+ concurrency : prod
49
+ environment :
50
+ name : prod
51
+ if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
52
+ steps :
53
+ - name : Checkout repository
54
+ uses : actions/checkout@v4
55
+ with :
56
+ repository : csesoc/deployment
57
+ token : ${{ secrets.GH_TOKEN }}
58
+ ref : develop
59
+ - name : Install yq - portable yaml processor
60
+
61
+ - name : Update deployment
62
+ env :
63
+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
64
+ run : |
65
+ git config user.name "CSESoc CD"
66
+ 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
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
0 commit comments