Deploy_To_Dev_Function_On_Push #1316
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |