|
14 | 14 | concurrency:
|
15 | 15 | group: ${{ github.workflow }}-${{ github.event.inputs.environment }}
|
16 | 16 |
|
| 17 | +env: |
| 18 | + IMAGE_NAME: tramsapi-app |
| 19 | + |
17 | 20 | jobs:
|
18 | 21 | set-env:
|
19 | 22 | name: Determine environment
|
20 | 23 | runs-on: ubuntu-24.04
|
21 | 24 | outputs:
|
22 | 25 | environment: ${{ steps.var.outputs.environment }}
|
23 |
| - branch: ${{ steps.var.outputs.branch }} |
24 | 26 | release: ${{ steps.var.outputs.release }}
|
25 |
| - checked-out-sha: ${{ steps.var.outputs.checked-out-sha }} |
| 27 | + image-name: ${{ steps.var.outputs.image-name }} |
26 | 28 | steps:
|
27 | 29 | - name: Checkout
|
28 | 30 | uses: actions/checkout@v4
|
29 | 31 |
|
30 |
| - - name: Get branch name for push/dispatch event |
31 |
| - run: | |
32 |
| - GIT_REF=${{ github.ref_name }} |
33 |
| - echo "branch_ref=${GIT_REF}" >> $GITHUB_ENV |
34 |
| -
|
35 | 32 | - id: var
|
36 | 33 | run: |
|
37 |
| - GIT_REF=${{ env.branch_ref }} |
38 |
| - GIT_BRANCH=${GIT_REF##*/} |
39 | 34 | INPUT=${{ github.event.inputs.environment }}
|
40 | 35 | ENVIRONMENT=${INPUT:-"development"}
|
41 |
| - CHECKED_OUT_SHA="$(git log -1 '--format=format:%H')" |
42 | 36 | RELEASE=${ENVIRONMENT,,}-`date +%Y-%m-%d`.${{ github.run_number }}
|
43 | 37 | echo "environment=${ENVIRONMENT,,}" >> $GITHUB_OUTPUT
|
44 |
| - echo "branch=$GIT_BRANCH" >> $GITHUB_OUTPUT |
45 |
| - echo "checked-out-sha=${CHECKED_OUT_SHA}" >> $GITHUB_OUTPUT |
46 | 38 | echo "release=${RELEASE}" >> $GITHUB_OUTPUT
|
| 39 | + echo "image-name=${{ env.IMAGE_NAME }}" >> $GITHUB_OUTPUT |
47 | 40 |
|
48 |
| - build-import-init-container: |
| 41 | + build: |
| 42 | + name: Build |
| 43 | + needs: [ set-env ] |
49 | 44 | permissions:
|
50 |
| - id-token: write |
51 |
| - contents: read |
52 | 45 | packages: write
|
53 |
| - name: Build and import Init Container |
54 |
| - needs: [ set-env ] |
55 |
| - uses: DFE-Digital/deploy-azure-container-apps-action/.github/workflows/build-push-deploy.yml@v3.1.0 |
| 46 | + uses: DFE-Digital/deploy-azure-container-apps-action/.github/workflows/build.yml@v4.1.0 |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + stage: [ |
| 50 | + "final", |
| 51 | + "initcontainer" |
| 52 | + ] |
| 53 | + include: |
| 54 | + - stage: "final" |
| 55 | + tag-prefix: "" |
| 56 | + - stage: "initcontainer" |
| 57 | + tag-prefix: "init-" |
56 | 58 | with:
|
57 |
| - docker-image-name: tramsapi-app |
58 |
| - docker-build-target: initcontainer |
59 |
| - docker-tag-prefix: init- |
60 | 59 | environment: ${{ needs.set-env.outputs.environment }}
|
61 |
| - import-without-deploy: true |
| 60 | + docker-image-name: ${{ needs.set-env.outputs.image-name }} |
| 61 | + docker-build-file-name: ${{ inputs.docker-build-file-name }} |
| 62 | + docker-build-context: ${{ inputs.docker-build-context }} |
62 | 63 | docker-build-args: CI=true
|
| 64 | + docker-build-target: ${{ matrix.stage }} |
| 65 | + docker-tag-prefix: ${{ matrix.tag-prefix }} |
| 66 | + |
| 67 | + import: |
| 68 | + name: Import |
| 69 | + needs: [ set-env, build ] |
| 70 | + permissions: |
| 71 | + id-token: write |
| 72 | + uses: DFE-Digital/deploy-azure-container-apps-action/.github/workflows/import.yml@v4.1.0 |
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + stage: [ |
| 76 | + "final", |
| 77 | + "initcontainer" |
| 78 | + ] |
| 79 | + include: |
| 80 | + - stage: "final" |
| 81 | + tag-prefix: "" |
| 82 | + - stage: "initcontainer" |
| 83 | + tag-prefix: "init-" |
| 84 | + with: |
| 85 | + environment: ${{ needs.set-env.outputs.environment }} |
| 86 | + docker-image-name: ${{ needs.set-env.outputs.image-name }} |
| 87 | + docker-tag-prefix: ${{ matrix.tag-prefix }} |
63 | 88 | secrets:
|
64 | 89 | azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
65 | 90 | azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
66 | 91 | azure-acr-client-id: ${{ secrets.ACR_CLIENT_ID }}
|
67 | 92 | azure-acr-name: ${{ secrets.ACR_NAME }}
|
68 |
| - azure-aca-client-id: ${{ secrets.ACA_CLIENT_ID }} |
69 |
| - azure-aca-name: ${{ secrets.ACA_CONTAINERAPP_NAME }} |
70 |
| - azure-aca-resource-group: ${{ secrets.ACA_RESOURCE_GROUP }} |
71 | 93 |
|
72 |
| - build-import-deploy-app: |
| 94 | + deploy: |
| 95 | + name: Deploy |
| 96 | + needs: [ set-env, import ] |
73 | 97 | permissions:
|
74 | 98 | id-token: write
|
75 |
| - contents: read |
76 |
| - packages: write |
77 |
| - name: Build, import and deploy App Container |
78 |
| - needs: [ build-import-init-container ] |
79 |
| - uses: DFE-Digital/deploy-azure-container-apps-action/.github/workflows/build-push-deploy.yml@v3.1.0 |
| 99 | + uses: DFE-Digital/deploy-azure-container-apps-action/.github/workflows/deploy.yml@v4.1.0 |
80 | 100 | with:
|
81 |
| - docker-image-name: tramsapi-app |
82 |
| - docker-build-target: final |
83 | 101 | environment: ${{ needs.set-env.outputs.environment }}
|
| 102 | + docker-image-name: ${{ needs.set-env.outputs.image-name }} |
84 | 103 | annotate-release: true
|
85 |
| - docker-build-args: | |
86 |
| - COMMIT_SHA="${{ needs.set-env.outputs.checked-out-sha }}" |
87 |
| - CI=true |
88 | 104 | secrets:
|
89 | 105 | azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
90 | 106 | azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
91 |
| - azure-acr-client-id: ${{ secrets.ACR_CLIENT_ID }} |
92 |
| - azure-acr-name: ${{ secrets.ACR_NAME }} |
93 | 107 | azure-aca-client-id: ${{ secrets.ACA_CLIENT_ID }}
|
94 | 108 | azure-aca-name: ${{ secrets.ACA_CONTAINERAPP_NAME }}
|
95 | 109 | azure-aca-resource-group: ${{ secrets.ACA_RESOURCE_GROUP }}
|
| 110 | + azure-acr-name: ${{ secrets.ACR_NAME }} |
96 | 111 |
|
97 | 112 | create-tag:
|
98 | 113 | name: Tag and release
|
99 |
| - needs: [ set-env, build-import-deploy-app ] |
| 114 | + needs: [ set-env, deploy ] |
100 | 115 | runs-on: ubuntu-24.04
|
101 | 116 | steps:
|
102 | 117 | - uses: actions/checkout@v4
|
@@ -147,7 +162,7 @@ jobs:
|
147 | 162 |
|
148 | 163 | cypress-tests:
|
149 | 164 | name: Run Cypress Tests
|
150 |
| - needs: [ set-env, create-tag ] |
| 165 | + needs: [ set-env, deploy ] |
151 | 166 | if: needs.set-env.outputs.environment == 'test' || needs.set-env.outputs.environment == 'development'
|
152 | 167 | uses: ./.github/workflows/cypress-tests.yml
|
153 | 168 | with:
|
|
0 commit comments