Skip to content

Deploy_To_Dev_Function_On_Push #1141

Deploy_To_Dev_Function_On_Push

Deploy_To_Dev_Function_On_Push #1141

name: Deploy_To_Dev_Function_On_Push
on:
workflow_dispatch:
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-deploy.yml'
- './pvt-post-solr-create-collections/exampleRequest.json'
branches:
- develop
schedule:
- cron: '17 04 * * *' # 0417am daily
env:
STAGE: dev # suffix to indicate environment stage
NAME: func-datastore-services
AZURE_CREDENTIALS: ${{ secrets.DEV_AZURE_CREDENTIALS }}
PGDATABASE: ${{ secrets.PGDATABASE_DEV }}
PGHOST: ${{ secrets.PGHOST_DEV }}
PGUSER: ${{ secrets.PGUSER_DEV }}
PGPASSWORD: ${{ secrets.PGPASSWORD_DEV }}
PGPORT: ${{ secrets.PGPORT }}
PGSSL: ${{ secrets.PGSSL }}
SOLR_URL: ${{ secrets.DEV_SOLR_API_URL }}
SOLR_USERNAME: ${{ secrets.DEV_SOLR_USER }}
SOLR_PASSWORD: ${{ secrets.DEV_SOLR_PASSWORD }}
STORAGE_CONNECTION_STRING: ${{ secrets.DEV_STORAGE_CONNECTION_STRING }}
DOWNLOAD_CONTAINER_NAME: ${{ secrets.DEV_DOWNLOAD_CONTAINER_NAME }}
KV_URI: ${{ secrets.DEV_KV_URI }}
API_KEY: ${{ secrets.DEV_VALIDATOR_SERVICES_KEY_VALUE }}
IATI_IDENTIFIERS_EXIST_MAX_NUMBER_OF_IDS: ${{ vars.DEV_IATI_IDENTIFIERS_EXIST_MAX_NUMBER_OF_IDS }}
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 for connecting to Redis instance and storing api keys in key vault
uses: Azure/[email protected]
with:
app-name: ${{env.NAME}}-${{env.STAGE}}
app-settings-json: |
[
{
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "~16",
"slotSetting": false
},
{
"name": "PGDATABASE",
"value": "${{ env.PGDATABASE }}",
"slotSetting": false
},
{
"name": "PGHOST",
"value": "${{ env.PGHOST }}",
"slotSetting": false
},
{
"name": "PGUSER",
"value": "${{ env.PGUSER }}",
"slotSetting": false
},
{
"name": "PGPASSWORD",
"value": "${{ env.PGPASSWORD }}",
"slotSetting": false
},
{
"name": "PGPORT",
"value": "${{ env.PGPORT }}",
"slotSetting": false
},
{
"name": "PGSSL",
"value": "${{ env.PGSSL }}",
"slotSetting": false
},
{
"name": "SOLR_URL",
"value": "${{ env.SOLR_URL }}",
"slotSetting": false
},
{
"name": "SOLR_USERNAME",
"value": "${{ env.SOLR_USERNAME }}",
"slotSetting": false
},
{
"name": "SOLR_PASSWORD",
"value": "${{ env.SOLR_PASSWORD }}",
"slotSetting": false
},
{
"name": "STORAGE_CONNECTION_STRING",
"value": "${{ env.STORAGE_CONNECTION_STRING }}",
"slotSetting": false
},
{
"name": "DOWNLOAD_CONTAINER_NAME",
"value": "${{ env.DOWNLOAD_CONTAINER_NAME }}",
"slotSetting": false
},
{
"name": "AzureWebJobsSecretStorageType",
"value": "keyvault",
"slotSetting": false
},
{
"name": "AzureWebJobsSecretStorageKeyVaultUri",
"value": "${{ env.KV_URI }}",
"slotSetting": false
},
{
"name": "IATI_IDENTIFIERS_EXIST_MAX_NUMBER_OF_IDS",
"value": "${{ env.IATI_IDENTIFIERS_EXIST_MAX_NUMBER_OF_IDS }}",
"slotSetting": false
}
]
- name: 'Run Azure Functions Action'
uses: Azure/[email protected]
with:
app-name: ${{ 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'
run: |
newman run integration-tests/datastore-services-integration-tests.postman_collection.json \
-e integration-tests/envs/func-datastore-services-dev.postman_environment.json \
--env-var keyValue=$API_KEY \
--delay-request 50
# 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