-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (142 loc) · 5.35 KB
/
Copy pathdeploy.yml
File metadata and controls
153 lines (142 loc) · 5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Deploy to environment
on:
push:
branches:
- main
workflow_dispatch:
inputs:
environment:
type: environment
description: "Choose an environment to deploy to"
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.environment }}-${{ github.run_number }}
env:
IMAGE_NAME: flexformsapi
permissions:
contents: read
packages: read
jobs:
set-env:
name: Preflight
runs-on: ubuntu-24.04
outputs:
environment: ${{ steps.var.outputs.environment }}
environment-lower: ${{ steps.var.outputs.environment-lower }}
branch: ${{ steps.var.outputs.branch }}
checked-out-sha: ${{ steps.var.outputs.checked-out-sha }}
image-name: ${{ steps.var.outputs.image-name }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- id: var
run: |
GIT_REF=${{ github.ref_name }}
GIT_BRANCH=${GIT_REF##*/}
INPUT="${{ github.event.inputs.environment }}"
ENVIRONMENT=${INPUT:-"development"}
CHECKED_OUT_SHA="$(git log -1 '--format=format:%H')"
TIME="$(date)"
echo "environment=${ENVIRONMENT}" >> $GITHUB_OUTPUT
echo "environment-lower=${ENVIRONMENT,,}" >> $GITHUB_OUTPUT
echo "branch=$GIT_BRANCH" >> $GITHUB_OUTPUT
echo "checked-out-sha=${CHECKED_OUT_SHA}" >> $GITHUB_OUTPUT
if [[ "$ENVIRONMENT" == fe-saas-api* ]]
then
echo "image-name=fe-saas-api" >> $GITHUB_OUTPUT
else
echo "image-name=${{ env.IMAGE_NAME }}" >> $GITHUB_OUTPUT
fi
validate-packages:
runs-on: windows-latest
name: Package Validation
permissions:
contents: read
needs: [ set-env ]
if: needs.set-env.outputs.environment-lower == 'production'
steps:
- name: Validate Packages
uses: DFE-Digital/rsd-github-actions/.github/actions/validate-packages@v1
with:
environment: ${{ needs.set-env.outputs.environment }}
test:
name: Run tests
needs: [ set-env ]
if: needs.set-env.outputs.environment-lower == 'production'
uses: ./.github/workflows/test-solution.yml
secrets: inherit
build-import:
name: Build & import (${{ matrix.target }}) → ${{ needs.set-env.outputs.environment }}
runs-on: ubuntu-24.04
needs: [ set-env, validate-packages, test ]
if: |
always() &&
needs.set-env.result == 'success' &&
(needs.validate-packages.result == 'success' || needs.validate-packages.result == 'skipped') &&
(needs.test.result == 'success' || needs.test.result == 'skipped')
environment: ${{ needs.set-env.outputs.environment }}
permissions:
attestations: write
packages: write
id-token: write
strategy:
matrix:
target: [
"final",
"initcontainer"
]
include:
- target: "final"
tag-prefix: ""
- target: "initcontainer"
tag-prefix: "init-"
steps:
- name: Build
uses: DFE-Digital/deploy-azure-container-apps-action/.github/actions/build@8e72e403f05ff9da09668207eef1d79e1ce9d1a7 # v5.2.1
with:
image-name: ${{ needs.set-env.outputs.image-name }}
build-args: CI=true
build-target: ${{ matrix.target }}
tag-prefix: ${{ matrix.tag-prefix }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Import
uses: DFE-Digital/deploy-azure-container-apps-action/.github/actions/import@8e72e403f05ff9da09668207eef1d79e1ce9d1a7 # v5.2.1
with:
image-name: ${{ needs.set-env.outputs.image-name }}
tag-prefix: ${{ matrix.tag-prefix }}
azure-acr-name: ${{ secrets.ACR_NAME }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
azure-acr-client-id: ${{ secrets.ACR_CLIENT_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID || '' }}
AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION_ID || '' }}
AZURE_ACR_CLIENT_ID: ${{ secrets.ACR_CLIENT_ID || '' }}
deploy:
name: Release → ${{ needs.set-env.outputs.environment }}
runs-on: ubuntu-24.04
needs: [ build-import, set-env ]
if: |
always() &&
needs.set-env.result == 'success' &&
needs.build-import.result == 'success'
environment: ${{ needs.set-env.outputs.environment }}
permissions:
id-token: write
steps:
- name: Release
uses: DFE-Digital/deploy-azure-container-apps-action/.github/actions/deploy@8e72e403f05ff9da09668207eef1d79e1ce9d1a7 # v5.2.1
with:
image-name: ${{ needs.set-env.outputs.image-name }}
annotate-release: 'yes'
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
azure-acr-name: ${{ secrets.ACR_NAME }}
azure-aca-client-id: ${{ secrets.ACA_CLIENT_ID }}
azure-aca-name: ${{ secrets.ACA_NAME }}
azure-aca-resource-group: ${{ secrets.ACA_RESOURCE_GROUP }}
env:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID || '' }}
AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION_ID || '' }}
AZURE_ACA_CLIENT_ID: ${{ secrets.ACA_CLIENT_ID || '' }}