-
Notifications
You must be signed in to change notification settings - Fork 5
76 lines (66 loc) · 2.97 KB
/
stage-4-deploy.yaml
File metadata and controls
76 lines (66 loc) · 2.97 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
name: Deployment stage
on:
workflow_call:
inputs:
environments:
description: List of environments to deploy to (String array)
required: true
type: string
commit_sha:
description: Commit SHA used to fetch ADO pipeline and docker image
required: true
type: string
pr_number:
description: Pull request number when used in a pull request
required: false
type: string
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
strategy:
matrix:
environment: ${{ fromJson(inputs.environments) }}
max-parallel: 1
environment: ${{ matrix.environment }}
# Prevent concurrent jobs on the same environment and between deploy and delete workflows
concurrency: deploy-${{ matrix.environment }}-${{inputs.pr_number}}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: azure/login@532459ea530d8321f2fb9bb10d1e0bcf23869a43 # v3
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Call deployment pipeline
env:
ENVIRONMENT: ${{ matrix.environment }}
COMMIT_SHA: ${{ inputs.commit_sha }}
PR_NUMBER: ${{ inputs.pr_number }}
run: |
if [[ -n "${PR_NUMBER}" ]]; then
pr_argument="prNumber=${PR_NUMBER}"
else
pr_argument=""
fi
source "infrastructure/environments/${ENVIRONMENT}/variables.sh"
echo "Starting Azure devops pipeline \"Deploy to Azure - ${ENVIRONMENT}\"..."
RUN_ID=$(az pipelines run \
--commit-id "${COMMIT_SHA}" \
--name "Deploy to Azure - ${ENVIRONMENT}" \
--org https://dev.azure.com/nhse-dtos \
--project dtos-manage-breast-screening \
--parameters commitSHA="${COMMIT_SHA}" ${pr_argument} environment="${ENVIRONMENT}" pool="${ADO_MANAGEMENT_POOL}" \
--output tsv --query id)
echo "See pipeline run in Azure devops: https://dev.azure.com/nhse-dtos/dtos-manage-breast-screening/_build/results?buildId=${RUN_ID}&view=results"
scripts/bash/wait_ado_pipeline.sh "$RUN_ID" https://dev.azure.com/nhse-dtos dtos-manage-breast-screening
- name: Basic application smoke test
env:
ENVIRONMENT: ${{ matrix.environment }}
COMMIT_SHA: ${{ inputs.commit_sha }}
PR_NUMBER: ${{ inputs.pr_number }}
run: |
dns_zone_name=$( grep dns_zone_name "infrastructure/environments/${ENVIRONMENT}/variables.tfvars" | awk -F'"' '{print $2}' )
use_apex_domain=$( grep use_apex_domain "infrastructure/environments/${ENVIRONMENT}/variables.tfvars" | awk '{print $3}' || echo "false" )
scripts/bash/container_app_smoke_test.sh "${ENVIRONMENT}" "${COMMIT_SHA}" "${dns_zone_name}" "${PR_NUMBER}" "${use_apex_domain}"