Skip to content

Deployment application stack trigger #7

Deployment application stack trigger

Deployment application stack trigger #7

name: Deployment application stack trigger
on:
push:
branches:
- DTOSS-13744-Manual-pipeline-to-deploy-gateways
workflow_dispatch:
inputs:
release_tag:
description: GitHub release tag to deploy (e.g. v1.2.3 or pr-42)
required: true
type: string
environment:
description: Environment to deploy to
required: true
type: choice
options:
- review
- dev
- preprod
- prod
permissions:
contents: read
id-token: write
jobs:
deploy:
name: Deploy ${{ inputs.environment }}
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
# Prevent concurrent app deployments to the same environment
concurrency: deploy-app-${{ inputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Azure login
uses: azure/login@532459ea530d8321f2fb9bb10d1e0bcf23869a43 # v3.0.0
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: ${{ inputs.environment }}
# ENVIRONMENT: ${{ github.event_name == 'workflow_dispatch' && inputs.environment || 'review' }}
RELEASE_TAG: ${{ inputs.release_tag }}
# RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || 'v1.8' }}
ADO_PROJECT: ${{ github.event.repository.name }}
GITHUB_TOKEN: ${{ github.token }}
run: |
source "infrastructure/environments/${ENVIRONMENT}/variables.sh"
echo "Starting Azure DevOps pipeline \"Deploy Gateway App - ${ENVIRONMENT}\"..."
RUN_ID=$(az pipelines run \
--name "Deploy Gateway App - ${ENVIRONMENT}" \
--org https://dev.azure.com/nhse-dtos \
--project "${ADO_PROJECT}" \
--parameters \
releaseTag="${RELEASE_TAG}" \
environment="${ENVIRONMENT}" \
pool="${ADO_MANAGEMENT_POOL}" \
githubToken="${GITHUB_TOKEN}" \
--output tsv \
--query id)
echo "See pipeline run in Azure DevOps: https://dev.azure.com/nhse-dtos/${ADO_PROJECT}/_build/results?buildId=${RUN_ID}&view=results"
scripts/bash/wait_ado_pipeline.sh \
"$RUN_ID" \
https://dev.azure.com/nhse-dtos \
"${ADO_PROJECT}"