1212 TF_WORKSPACE : ${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }}
1313
1414jobs :
15- check-new- pretix-version :
15+ check-pretix-build :
1616 name : Check pretix needs building
1717 runs-on : ubuntu-24.04
1818 outputs :
@@ -48,60 +48,13 @@ jobs:
4848 build-pretix :
4949 name : Build pretix
5050 runs-on : [self-hosted]
51- needs : [check-new-pretix-version]
52- if : ${{ needs.check-new-pretix-version.outputs.image_exists == 0 }}
53- steps :
54- - uses : actions/checkout@v4
55- with :
56- ref : ${{ github.ref }}
57- fetch-depth : 0
58- - name : Configure AWS credentials
59- uses : aws-actions/configure-aws-credentials@v4
60- with :
61- aws-access-key-id : ${{ secrets.aws_access_key_id }}
62- aws-secret-access-key : ${{ secrets.aws_secret_access_key }}
63- aws-region : eu-central-1
64- - uses : actions/checkout@v4
65- with :
66- repository : pretix/pretix
67- ref : v2024.10.0
68- path : ./pretix-clone
69- - name : Login to Amazon ECR
70- uses : aws-actions/amazon-ecr-login@v2
71- - name : Set up Docker Buildx
72- id : buildx
73- uses : docker/setup-buildx-action@v3
74- - name : Build pretix base
75- uses : docker/build-push-action@v6
76- id : build-pretix-base
77- with :
78- context : ./pretix-clone
79- file : ./pretix-clone/Dockerfile
80- builder : ${{ steps.buildx.outputs.name }}
81- provenance : false
82- push : true
83- tags : |
84- ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pretix:pretix-base-${{ needs.check-new-pretix-version.outputs.githash }}
85- cache-from : type=local,src=/tmp/.buildx-cache
86- cache-to : type=local,dest=/tmp/.buildx-cache
87- platforms : linux/arm64
88- - name : Build and push pretix
89- uses : docker/build-push-action@v6
90- with :
91- context : ./pretix
92- file : ./pretix/Dockerfile
93- builder : ${{ steps.buildx.outputs.name }}
94- provenance : false
95- push : true
96- tags : |
97- ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pretix:arm-${{ needs.check-new-pretix-version.outputs.githash }}
98- cache-from : type=local,src=/tmp/.buildx-cache
99- cache-to : type=local,dest=/tmp/.buildx-cache
100- platforms : linux/arm64
101- build-args : |
102- PRETIX_IMAGE=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pretix:pretix-base-${{ needs.check-new-pretix-version.outputs.githash }}
51+ needs : [check-pretix-build]
52+ if : ${{ needs.check-pretix-build.outputs.image_exists == 0 }}
53+ uses : ./.github/actions/build-pretix.yml
54+ with :
55+ githash : ${{ needs.check-pretix-build.outputs.githash }}
10356
104- check-new- backend-version :
57+ check-backend-build :
10558 name : Check backend needs building
10659 runs-on : ubuntu-24.04
10760 outputs :
@@ -112,6 +65,12 @@ jobs:
11265 with :
11366 ref : ${{ github.ref }}
11467 fetch-depth : 0
68+ - name : Configure AWS credentials
69+ uses : aws-actions/configure-aws-credentials@v4
70+ with :
71+ aws-access-key-id : ${{ secrets.aws_access_key_id }}
72+ aws-secret-access-key : ${{ secrets.aws_secret_access_key }}
73+ aws-region : eu-central-1
11574 - name : Get service githash
11675 id : git
11776 run : |
13190 build-be :
13291 name : Build backend
13392 runs-on : [self-hosted]
134- needs : [check-new- backend-version ]
135- if : ${{ needs.check-new- backend-version .outputs.image_exists == 0 }}
93+ needs : [check-backend-build ]
94+ if : ${{ needs.check-backend-build .outputs.image_exists == 0 }}
13695 steps :
13796 - name : Configure AWS credentials
13897 uses : aws-actions/configure-aws-credentials@v4
@@ -156,7 +115,7 @@ jobs:
156115 provenance : false
157116 push : true
158117 tags : |
159- ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pycon-backend:arm-${{ needs.check-new- backend-version .outputs.githash }}
118+ ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pycon-backend:arm-${{ needs.check-backend-build .outputs.githash }}
160119 cache-from : type=local,src=/tmp/.buildx-cache
161120 cache-to : type=local,dest=/tmp/.buildx-cache
162121 platforms : linux/arm64
@@ -196,8 +155,9 @@ jobs:
196155 AWS_DEFAULT_REGION : eu-central-1
197156
198157 wait-be-update :
158+ name : Wait backend deployment
199159 runs-on : ubuntu-24.04
200- needs : [deploy-be, build-be, check-new- backend-version ]
160+ needs : [deploy-be, build-be, check-backend-build ]
201161 steps :
202162 - uses : actions/checkout@v4
203163 with :
@@ -207,17 +167,46 @@ jobs:
207167 uses : ./.github/actions/wait-for-deployment
208168 with :
209169 url : https://${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it/health/
210- githash : ${{ needs.check-new-backend-version.outputs.githash }}
170+ githash : ${{ needs.check-backend-build.outputs.githash }}
171+
172+ check-frontend-build :
173+ name : Check frontend needs building
174+ runs-on : ubuntu-24.04
175+ outputs :
176+ image_exists : ${{ steps.image.outputs.image_exists }}
177+ githash : ${{ steps.git.outputs.githash }}
178+ steps :
179+ - uses : actions/checkout@v4
180+ with :
181+ ref : ${{ github.ref }}
182+ fetch-depth : 0
183+ - name : Configure AWS credentials
184+ uses : aws-actions/configure-aws-credentials@v4
185+ with :
186+ aws-access-key-id : ${{ secrets.aws_access_key_id }}
187+ aws-secret-access-key : ${{ secrets.aws_secret_access_key }}
188+ aws-region : eu-central-1
189+ - name : Get service githash
190+ id : git
191+ run : |
192+ hash=$(git rev-list -1 HEAD -- frontend)
193+ echo "githash=$hash" >> $GITHUB_OUTPUT
194+ - name : Check if commit is already on ECR
195+ id : image
196+ run : |
197+ set +e
198+ aws ecr describe-images --repository-name=pythonit/${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }}-pycon-frontend --image-ids=imageTag=${{ steps.git.outputs.githash }}
199+ if [[ $? == 0 ]]; then
200+ echo "image_exists=1" >> $GITHUB_OUTPUT
201+ else
202+ echo "image_exists=0" >> $GITHUB_OUTPUT
203+ fi
211204
212205 build-fe :
213206 name : Build frontend
214- needs : [wait-be-update]
207+ needs : [wait-be-update, check-frontend-build ]
215208 runs-on : [self-hosted]
216- permissions :
217- packages : write
218- contents : read
219- outputs :
220- githash : ${{ steps.git.outputs.githash }}
209+ if : ${{ needs.check-frontend-build.outputs.image_exists == 0 }}
221210 steps :
222211 - uses : actions/checkout@v4
223212 with :
@@ -245,18 +234,14 @@ jobs:
245234 echo "image_exists=0" >> $GITHUB_OUTPUT
246235 fi
247236 - name : Set up QEMU dependency
248- if : ${{ steps.image.outputs.image_exists == 0 }}
249237 uses : docker/setup-qemu-action@v3
250238 - name : Login to Amazon ECR
251- if : ${{ steps.image.outputs.image_exists == 0 }}
252239 uses : aws-actions/amazon-ecr-login@v2
253240 - name : Set up Docker Buildx
254241 id : buildx
255- if : ${{ steps.image.outputs.image_exists == 0 }}
256242 uses : docker/setup-buildx-action@v3
257243 - name : Get vars
258244 id : vars
259- if : ${{ steps.image.outputs.image_exists == 0 }}
260245 run : |
261246 cms_hostname=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/pycon-frontend/cms-hostname)
262247 echo "CMS_HOSTNAME=$cms_hostname" >> "$GITHUB_OUTPUT"
@@ -268,7 +253,6 @@ jobs:
268253 echo "::add-mask::$sentry_auth_token"
269254 echo "SENTRY_AUTH_TOKEN=$sentry_auth_token" >> "$GITHUB_OUTPUT"
270255 - name : Build and push
271- if : ${{ steps.image.outputs.image_exists == 0 }}
272256 uses : docker/build-push-action@v6
273257 with :
274258 context : ./frontend
@@ -326,8 +310,9 @@ jobs:
326310 AWS_DEFAULT_REGION : eu-central-1
327311
328312 wait-fe-update :
313+ name : Wait frontend deployment
329314 runs-on : ubuntu-24.04
330- needs : [deploy-fe, build-fe ]
315+ needs : [deploy-fe, check-frontend-build ]
331316 steps :
332317 - uses : actions/checkout@v4
333318 with :
@@ -337,4 +322,4 @@ jobs:
337322 uses : ./.github/actions/wait-for-deployment
338323 with :
339324 url : https://${{ fromJSON('["pastaporto-frontend", "frontend"]')[github.ref == 'refs/heads/main'] }}.pycon.it/api/health
340- githash : ${{ needs.build-fe .outputs.githash }}
325+ githash : ${{ needs.check-frontend-build .outputs.githash }}
0 commit comments