Skip to content

Deployment stage

Deployment stage #18

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
workflow_dispatch:
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
permissions:
id-token: write
contents: read
strategy:
matrix:
environment: ${{ fromJson(inputs.environments) }}
max-parallel: 1
environment: ${{ matrix.environment }}
concurrency: deploy-${{ matrix.environment }}-${{ github.ref }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Make script executable
run: chmod +x scripts/bash/wait_ado_pipeline.sh
- name: Call deployment pipeline
run: |
# Define common variables
organisation='https://dev.azure.com/nhse-dtos'
project_name='dtos-cohort-manager'
# Define which tests to run based on the environment
declare -A test_types=(
["dev"]="smoke_e2e,regression_api,regression_e2e_epic1,regression_e2e_epic2,regression_e2e_epic3"
["nft"]="smoke_e2e,regression_api,regression_e2e_epic1,regression_e2e_epic2,regression_e2e_epic3"
["int"]=""
["sandbox"]="smoke_e2e,regression_api"
["pre"]=""
["prod"]=""
)
git_short_sha=$(git rev-parse --short ${{inputs.commit_sha}})
parameters="dockerImageTag=${git_short_sha} testTypes=[${test_types[${{ matrix.environment }}]}]"
echo "Starting Azure devops pipeline \"Deploy to Azure - Core ${{ matrix.environment }}\"..."
RUN_ID=$(az pipelines run \
--commit-id ${{inputs.commit_sha}} \
--name "Deploy to Azure - Core ${{ matrix.environment }}" \
--org "${organisation}" \
--project "${project_name}" \
--parameters $parameters \
--output tsv --query id)
echo "Click here to view the ADO pipeline: ${organisation}/${project_name}/_build/results?buildId=${RUN_ID}"
scripts/bash/wait_ado_pipeline.sh "$RUN_ID" "${organisation}" "${project_name}" 1800