1212 TF_WORKSPACE : ${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }}
1313
1414jobs :
15- # create-db:
16- # runs-on: ubuntu-24.04
17- # defaults:
18- # run:
19- # working-directory: ./infrastructure/applications
20- # steps:
21- # - uses: actions/checkout@v4
22- # if: github.ref != 'refs/heads/main'
23- # with:
24- # ref: ${{ github.ref }}
25- # fetch-depth: 0
26- # - name: Configure AWS credentials
27- # if: github.ref != 'refs/heads/main'
28- # uses: aws-actions/configure-aws-credentials@v4
29- # with:
30- # aws-access-key-id: ${{ secrets.aws_access_key_id }}
31- # aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
32- # aws-region: eu-central-1
33- # - uses: hashicorp/setup-terraform@v3
34- # if: github.ref != 'refs/heads/main'
35- # with:
36- # terraform_version: 1.2.4
37- # - name: Terraform Init
38- # if: github.ref != 'refs/heads/main'
39- # run: terraform init
40- # env:
41- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42- # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
43- # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
44- # - name: Terraform apply
45- # if: github.ref != 'refs/heads/main'
46- # run: terraform apply -target module.database -no-color -auto-approve &> /dev/null
47- # env:
48- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49- # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
50- # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
51- # AWS_DEFAULT_REGION: eu-central-1
52-
5315 build-pretix :
5416 runs-on : [self-hosted]
5517 steps :
@@ -234,6 +196,7 @@ jobs:
234196 import os
235197 import time
236198
199+ attempts = 0
237200 while True:
238201 response = requests.get(f"https://{os.getenv('URL')}/health/")
239202 try:
@@ -243,9 +206,16 @@ jobs:
243206 break
244207 else:
245208 print('Commit hash does not match. Retrying...')
246- time.sleep(2)
247209 except e:
248210 print('Failed to get version', e)
211+
212+ attempts += 1
213+
214+ if attempts > 30:
215+ print('Failed to get new version')
216+ exit(1)
217+
218+ time.sleep(2)
249219 shell : python
250220 env :
251221 AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -381,19 +351,34 @@ jobs:
381351 steps :
382352 - name : Wait stable deployment
383353 run : |
384- while true; do
385- response=$(curl -s "https://${{ fromJSON('["pastaporto-frontend", "frontend"]')[github.ref == 'refs/heads/main'] }}.pycon.it/api/health")
386- commit=$(echo $response | jq -r '.version')
387- if [ "$commit" == "${{ needs.build-fe.outputs.githash }}" ]; then
388- echo "New version live"
389- break
390- else
391- echo "Commit hash does not match. Retrying..."
392- sleep 3
393- fi
394- done
395- shell : bash
354+ import requests
355+ import os
356+ import time
357+
358+ attempts = 0
359+ while True:
360+ response = requests.get(f"https://{os.getenv('URL')}/api/health")
361+ try:
362+ commit = response.json()['version']
363+ if commit == os.getenv('GITHASH'):
364+ print('New version live')
365+ break
366+ else:
367+ print('Commit hash does not match. Retrying...')
368+ except e:
369+ print('Failed to get version', e)
370+
371+ attempts += 1
372+
373+ if attempts > 30:
374+ print('Failed to get new version')
375+ exit(1)
376+
377+ time.sleep(2)
378+ shell : python
396379 env :
397380 AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
398381 AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
399382 AWS_DEFAULT_REGION : eu-central-1
383+ URL : ${{ fromJSON('["pastaporto-frontend", "frontend"]')[github.ref == 'refs/heads/main'] }}.pycon.it
384+ GITHASH : ${{ needs.build-fe.outputs.githash }}
0 commit comments