-
Notifications
You must be signed in to change notification settings - Fork 1
200 lines (184 loc) · 7 KB
/
develop-func-deploy.yml
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Deploy_To_Dev_Function_On_Push
on:
workflow_dispatch: # Allow Manual Run from GitHub
push:
paths-ignore: # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- "**/README.md" # don't run on README.md file updates anywhere in repo
- "**/dependabot.yml"
- ".github/workflows/prod-func-ci.yml"
- ".github/workflows/prod-func-deploy.yml"
- "docs/*"
branches:
- develop
schedule:
- cron: "19 04 * * *" # 0419am daily
env:
NAME: validator-services
STAGE: dev # postfix to indicate environment stage
TAG: ${{ github.sha }}
PGUSER: ${{ secrets.PGUSER }}
PGPASSWORD: ${{ secrets.PGPASSWORD }}
PGHOST: ${{ secrets.PGHOST }}
PGDATABASE: ${{ secrets.PGDATABASE }}
PGPORT: ${{ secrets.PGPORT }}
STORAGECONNECTOR: ${{ secrets.DEV_STORAGE_CONNECTION_STRING }}
ADHOC_CONTAINER: ${{ secrets.DEV_ADHOC_CONTAINER }}
VALIDATOR_API_URL: ${{ secrets.VALIDATOR_API_URL }}
VALIDATOR_FUNC_KEY: ${{ secrets.VALIDATOR_FUNC_KEY }}
API_KEY: ${{ secrets.DEV_DEFAULT_KEY }}
KV_URI: ${{ secrets.DEV_KV_URI }}
ACR_LOGIN_SERVER: ${{ secrets.ACR_LOGIN_SERVER }}
ACR_USERNAME: ${{ secrets.ACR_USERNAME }}
ACR_PASSWORD: ${{ secrets.ACR_PASSWORD }}
AZURE_CREDENTIALS: ${{ secrets.DEV_AZURE_CREDENTIALS }}
MAINTENANCE_MODE: ${{ secrets.DEV_MAINTENANCE_MODE }}
MAINTENANCE_MODE_MESSAGE: ${{ secrets.DEV_MAINTENANCE_MODE_MESSAGE }}
jobs:
should_run:
uses: IATI/.github/.github/workflows/should_run.yaml@main
build_save:
needs: should_run
if: ${{ needs.should_run.outputs.should_run == 'true' }}
uses: IATI/.github/.github/workflows/build_node_save.yaml@main
with:
npm_version: ^10
save_artifact: true
artifact_name: build-artifact-dev
deploy:
needs: build_save
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-dev
- name: Unzip build artifact
run: |
unzip build-artifact-dev.zip
rm build-artifact-dev.zip
- name: "Login via Azure CLI"
uses: azure/[email protected]
with:
creds: ${{ env.AZURE_CREDENTIALS }} # Service Principal credentials saved in GitHub Secrets
- name: Set Env variables on app service
uses: Azure/[email protected]
with:
app-name: "func-${{env.NAME}}-${{env.STAGE}}"
app-settings-json: |
[
{
"name": "PGDATABASE",
"value": "${{ env.PGDATABASE }}",
"slotSetting": false
},
{
"name": "PGUSER",
"value": "${{ env.PGUSER }}",
"slotSetting": false
},
{
"name": "PGPASSWORD",
"value": "${{ env.PGPASSWORD }}",
"slotSetting": false
},
{
"name": "PGHOST",
"value": "${{ env.PGHOST }}",
"slotSetting": false
},
{
"name": "PGPORT",
"value": "${{ env.PGPORT }}",
"slotSetting": false
},
{
"name": "PGSSL",
"value": "true",
"slotSetting": false
},
{
"name": "STORAGECONNECTOR",
"value": "${{ env.STORAGECONNECTOR }}",
"slotSetting": false
},
{
"name": "ADHOC_CONTAINER",
"value": "${{ env.ADHOC_CONTAINER }}",
"slotSetting": false
},
{
"name": "VALIDATOR_API_URL",
"value": "${{ env.VALIDATOR_API_URL }}",
"slotSetting": false
},
{
"name": "VALIDATOR_FUNC_KEY",
"value": "${{ env.VALIDATOR_FUNC_KEY }}",
"slotSetting": false
},
{
"name": "AzureWebJobsSecretStorageType",
"value": "keyvault",
"slotSetting": false
},
{
"name": "AzureWebJobsSecretStorageKeyVaultUri",
"value": "${{ env.KV_URI }}",
"slotSetting": false
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "node",
"slotSetting": false
},
{
"name": "MAINTENANCE_MODE",
"value": "${{ env.MAINTENANCE_MODE }}",
"slotSetting": false
},
{
"name": "MAINTENANCE_MODE_MESSAGE",
"value": "${{ env.MAINTENANCE_MODE_MESSAGE }}",
"slotSetting": false
}
]
- name: "Run Azure Functions Action"
uses: Azure/[email protected]
with:
app-name: func-${{ env.NAME }}-${{ env.STAGE }}
integration-test:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: "Wait for 3 minutes"
run: sleep 180
- name: "Checkout GitHub Action"
uses: actions/checkout@v4
- name: "Install newman"
run: |
sudo npm i -g newman
- name: "Run integration tests (when MAINTENANCE_MODE turned off)"
if: env.MAINTENANCE_MODE == 'DISABLED'
run: |
newman run integration-tests/validator-services-tests.postman_collection.json \
-e integration-tests/envs/validator-services-direct-dev.postman_environment.json \
--env-var keyValue=$API_KEY \
--working-dir integration-tests/test-files
- name: "Run integration tests (when MAINTENANCE_MODE turned on)"
if: env.MAINTENANCE_MODE != 'DISABLED'
run: |
newman run integration-tests/validator-services-tests.postman_collection.json \
-e integration-tests/envs/validator-services-direct-dev.postman_environment.json \
--env-var keyValue=$API_KEY \
--env-var testingMaintenanceMode=true \
--working-dir integration-tests/test-files \
--folder Initialisation --folder 'Publishers and Documents' --folder 'Guidance Links' --folder 'Flagged Publishers' --folder Statistics --folder 'Maintenance Mode'
# Mark status checks success/fail on dependabot commits for scheduled deploys
status_check_success:
needs: [deploy, integration-test]
if: success() && github.event_name == 'schedule'
uses: IATI/.github/.github/workflows/status_check_success.yaml@main
status_check_failure:
needs: [deploy, integration-test]
if: failure() && github.event_name == 'schedule'
uses: IATI/.github/.github/workflows/status_check_failure.yaml@main