diff --git a/.github/workflows/cicd-1-pull-request.yaml b/.github/workflows/cicd-1-pull-request.yaml index 1fc66d7..6cf5b71 100644 --- a/.github/workflows/cicd-1-pull-request.yaml +++ b/.github/workflows/cicd-1-pull-request.yaml @@ -34,6 +34,7 @@ jobs: with: environments: '["review"]' commit_sha: ${{ github.event.pull_request.head.sha }} + branch_name: ${{ github.event.pull_request.head.ref }} secrets: inherit # Build and publish a pre-release when the 'deploy' label is present. @@ -58,4 +59,5 @@ jobs: environments: '["review"]' release_tag: pr-${{ github.event.pull_request.number }} commit_sha: ${{ github.event.pull_request.head.sha }} + branch_name: ${{ github.event.pull_request.head.ref }} secrets: inherit diff --git a/.github/workflows/cicd-2-main-branch.yaml b/.github/workflows/cicd-2-main-branch.yaml index 94f14e1..dabe8b4 100644 --- a/.github/workflows/cicd-2-main-branch.yaml +++ b/.github/workflows/cicd-2-main-branch.yaml @@ -134,6 +134,7 @@ jobs: with: environments: '["dev"]' commit_sha: ${{ github.sha }} + branch_name: ${{ github.ref_name }} secrets: inherit deploy-app-dev: @@ -147,6 +148,7 @@ jobs: environments: '["dev"]' release_tag: ${{ needs.resolve.outputs.release_tag }} commit_sha: ${{ github.sha }} + branch_name: ${{ github.ref_name }} secrets: inherit # ---- preprod -------------------------------------------------------------- @@ -164,6 +166,7 @@ jobs: with: environments: '["preprod"]' commit_sha: ${{ github.sha }} + branch_name: ${{ github.ref_name }} secrets: inherit deploy-app-preprod: @@ -180,6 +183,7 @@ jobs: environments: '["preprod"]' release_tag: ${{ needs.resolve.outputs.release_tag }} commit_sha: ${{ github.sha }} + branch_name: ${{ github.ref_name }} secrets: inherit # ---- review (manual only) ------------------------------------------------- @@ -194,6 +198,7 @@ jobs: with: environments: '["review"]' commit_sha: ${{ github.sha }} + branch_name: ${{ github.ref_name }} secrets: inherit deploy-app-review: @@ -207,4 +212,5 @@ jobs: environments: '["review"]' release_tag: ${{ needs.resolve.outputs.release_tag }} commit_sha: ${{ github.sha }} + branch_name: ${{ github.ref_name }} secrets: inherit diff --git a/.github/workflows/cicd-3-release.yaml b/.github/workflows/cicd-3-release.yaml index 58289e6..cd21d36 100644 --- a/.github/workflows/cicd-3-release.yaml +++ b/.github/workflows/cicd-3-release.yaml @@ -42,6 +42,7 @@ jobs: environment: dev release_tag: ${{ github.ref_name }} commit_sha: ${{ github.sha }} + branch_name: main secrets: inherit deploy-preprod: @@ -52,6 +53,7 @@ jobs: environment: preprod release_tag: ${{ github.ref_name }} commit_sha: ${{ github.sha }} + branch_name: main secrets: inherit prod-approval: @@ -71,4 +73,5 @@ jobs: environment: prod release_tag: ${{ github.ref_name }} commit_sha: ${{ github.sha }} + branch_name: main secrets: inherit diff --git a/.github/workflows/stage-4-deploy-app.yaml b/.github/workflows/stage-4-deploy-app.yaml index 67c60f4..9bb7994 100644 --- a/.github/workflows/stage-4-deploy-app.yaml +++ b/.github/workflows/stage-4-deploy-app.yaml @@ -15,6 +15,11 @@ on: description: Commit SHA used to trigger the ADO pipeline required: true type: string + branch_name: + description: Git branch containing commit_sha + required: false + default: "main" + type: string jobs: deploy: @@ -46,13 +51,16 @@ jobs: ENVIRONMENT: ${{ matrix.environment }} RELEASE_TAG: ${{ inputs.release_tag }} COMMIT_SHA: ${{ inputs.commit_sha }} + BRANCH_NAME: ${{ inputs.branch_name }} ADO_PROJECT: ${{ github.event.repository.name }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | source "infrastructure/environments/${ENVIRONMENT}/variables.sh" + SOURCE_BRANCH="${BRANCH_NAME:-main}" echo "Starting Azure DevOps pipeline \"Deploy Gateway App - ${ENVIRONMENT}\"..." RUN_ID=$(az pipelines run \ + --branch "${SOURCE_BRANCH}" \ --commit-id "${COMMIT_SHA}" \ --name "Deploy Gateway App - ${ENVIRONMENT}" \ --org https://dev.azure.com/nhse-dtos \ diff --git a/.github/workflows/stage-4-deploy-env.yaml b/.github/workflows/stage-4-deploy-env.yaml index c1b9b2d..947cfac 100644 --- a/.github/workflows/stage-4-deploy-env.yaml +++ b/.github/workflows/stage-4-deploy-env.yaml @@ -15,6 +15,11 @@ on: description: Commit SHA used to trigger the ADO pipeline required: true type: string + branch_name: + description: Git branch containing commit_sha + required: false + default: "main" + type: string jobs: deploy-infra: @@ -25,6 +30,7 @@ jobs: with: environments: '["${{ inputs.environment }}"]' commit_sha: ${{ inputs.commit_sha }} + branch_name: ${{ inputs.branch_name }} secrets: inherit deploy-app: @@ -37,6 +43,7 @@ jobs: environments: '["${{ inputs.environment }}"]' release_tag: ${{ inputs.release_tag }} commit_sha: ${{ inputs.commit_sha }} + branch_name: ${{ inputs.branch_name }} secrets: inherit smoke-test: diff --git a/.github/workflows/stage-4-deploy.yaml b/.github/workflows/stage-4-deploy.yaml index b8a7818..370c8fc 100644 --- a/.github/workflows/stage-4-deploy.yaml +++ b/.github/workflows/stage-4-deploy.yaml @@ -11,6 +11,11 @@ on: description: Commit SHA used to trigger the ADO pipeline required: true type: string + branch_name: + description: Git branch containing commit_sha + required: false + default: "main" + type: string jobs: deploy: @@ -41,12 +46,15 @@ jobs: env: ENVIRONMENT: ${{ matrix.environment }} COMMIT_SHA: ${{ inputs.commit_sha }} + BRANCH_NAME: ${{ inputs.branch_name }} ADO_PROJECT: ${{ github.event.repository.name }} run: | source "infrastructure/environments/${ENVIRONMENT}/variables.sh" + SOURCE_BRANCH="${BRANCH_NAME:-main}" echo "Starting Azure devops pipeline \"Deploy to Azure - ${ENVIRONMENT}\"..." RUN_ID=$(az pipelines run \ + --branch "${SOURCE_BRANCH}" \ --commit-id "${COMMIT_SHA}" \ --name "Deploy to Azure - ${ENVIRONMENT}" \ --org https://dev.azure.com/nhse-dtos \