|
12 | 12 | TF_WORKSPACE: ${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }} |
13 | 13 |
|
14 | 14 | jobs: |
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 | | - |
53 | 15 | build-pretix: |
54 | 16 | runs-on: [self-hosted] |
55 | 17 | steps: |
|
128 | 90 | permissions: |
129 | 91 | packages: write |
130 | 92 | contents: read |
| 93 | + outputs: |
| 94 | + githash: ${{ steps.git.outputs.githash }} |
131 | 95 |
|
132 | 96 | steps: |
133 | 97 | - uses: actions/checkout@v4 |
@@ -190,7 +154,7 @@ jobs: |
190 | 154 |
|
191 | 155 | deploy-be: |
192 | 156 | runs-on: ubuntu-24.04 |
193 | | - needs: [build-be, build-pretix, create-db] |
| 157 | + needs: [build-be, build-pretix] |
194 | 158 | environment: |
195 | 159 | name: ${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }} |
196 | 160 | defaults: |
@@ -224,34 +188,26 @@ jobs: |
224 | 188 |
|
225 | 189 | wait-be-update: |
226 | 190 | runs-on: ubuntu-24.04 |
227 | | - needs: [deploy-be] |
| 191 | + needs: [deploy-be, build-be] |
228 | 192 | steps: |
| 193 | + - uses: actions/checkout@v4 |
| 194 | + with: |
| 195 | + ref: ${{ github.ref }} |
| 196 | + fetch-depth: 0 |
229 | 197 | - name: Wait stable deployment |
230 | | - run: | |
231 | | - while true; do |
232 | | - response=$(curl -s "https://${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it/health") |
233 | | - commit=$(echo $response | jq -r '.commit') |
234 | | - if [ "$commit" == "${{ steps.git.outputs.githash }}" ]; then |
235 | | - echo "New version live" |
236 | | - break |
237 | | - else |
238 | | - echo "Commit hash does not match. Retrying..." |
239 | | - sleep 3 |
240 | | - fi |
241 | | - done |
242 | | - shell: bash |
243 | | - env: |
244 | | - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
245 | | - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
246 | | - AWS_DEFAULT_REGION: eu-central-1 |
| 198 | + uses: ./.github/actions/wait-for-deployment |
| 199 | + with: |
| 200 | + url: https://${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it/health/ |
| 201 | + githash: ${{ needs.build-be.outputs.githash }} |
247 | 202 |
|
248 | 203 | build-fe: |
249 | 204 | needs: [wait-be-update] |
250 | 205 | runs-on: [self-hosted] |
251 | 206 | permissions: |
252 | 207 | packages: write |
253 | 208 | contents: read |
254 | | - |
| 209 | + outputs: |
| 210 | + githash: ${{ steps.git.outputs.githash }} |
255 | 211 | steps: |
256 | 212 | - uses: actions/checkout@v4 |
257 | 213 | with: |
@@ -367,23 +323,14 @@ jobs: |
367 | 323 |
|
368 | 324 | wait-fe-update: |
369 | 325 | runs-on: ubuntu-24.04 |
370 | | - needs: [deploy-fe] |
| 326 | + needs: [deploy-fe, build-fe] |
371 | 327 | steps: |
| 328 | + - uses: actions/checkout@v4 |
| 329 | + with: |
| 330 | + ref: ${{ github.ref }} |
| 331 | + fetch-depth: 0 |
372 | 332 | - name: Wait stable deployment |
373 | | - run: | |
374 | | - while true; do |
375 | | - response=$(curl -s "https://${{ fromJSON('["pastaporto-frontend", "frontend"]')[github.ref == 'refs/heads/main'] }}.pycon.it/api/health") |
376 | | - commit=$(echo $response | jq -r '.commit') |
377 | | - if [ "$commit" == "${{ steps.git.outputs.githash }}" ]; then |
378 | | - echo "New version live" |
379 | | - break |
380 | | - else |
381 | | - echo "Commit hash does not match. Retrying..." |
382 | | - sleep 3 |
383 | | - fi |
384 | | - done |
385 | | - shell: bash |
386 | | - env: |
387 | | - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
388 | | - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
389 | | - AWS_DEFAULT_REGION: eu-central-1 |
| 333 | + uses: ./.github/actions/wait-for-deployment |
| 334 | + with: |
| 335 | + url: https://${{ fromJSON('["pastaporto-frontend", "frontend"]')[github.ref == 'refs/heads/main'] }}.pycon.it/api/health |
| 336 | + githash: ${{ needs.build-fe.outputs.githash }} |
0 commit comments