Skip to content

Commit

Permalink
Merge pull request #1045 from DFE-Digital/mb-add-workflow-dispatch
Browse files Browse the repository at this point in the history
Add workflow_dispatch trigger to build and deploy
  • Loading branch information
malcolmbaig authored Mar 4, 2024
2 parents 253908b + a342a35 commit 25e0814
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ on:
- opened
- converted_to_draft

workflow_dispatch:
inputs:
environment:
description: "Environment"
required: true
type: choice
options:
- development
- test
- preproduction
- production

env:
CONTAINER_REGISTRY: ghcr.io

Expand Down Expand Up @@ -60,16 +72,32 @@ jobs:
message: |
AKS review app deployed to https://find-a-lost-trn-review-pr-${{ github.event.pull_request.number }}.test.teacherservices.cloud
set_matrix:
name: Set deployment matrix
runs-on: ubuntu-latest
needs: [docker]
outputs:
deployment_matrix: ${{ steps.set_matrix.outputs.deployment_matrix }}
steps:
- id: set_matrix
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
DEPLOYMENT_MATRIX="{ 'environment': ['${{ github.event.inputs.environment }}'] }"
else
DEPLOYMENT_MATRIX="{ 'environment': ['development', 'test', 'preproduction'] }"
fi
echo "deployment_matrix=$DEPLOYMENT_MATRIX" >> $GITHUB_OUTPUT
deploy_nonprod:
name: Deploy to ${{ matrix.environment }} environment
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
concurrency: deploy_${{ matrix.environment }}
needs: [docker]
needs: [docker, set_matrix]
strategy:
max-parallel: 1
matrix:
environment: [development, test, preproduction]
fail-fast: false # this is necessary to prevent early terminiation of terraform deployments that will result in tfstate locks
max-parallel: 3
matrix: ${{ fromJson(needs.set_matrix.outputs.deployment_matrix) }}
environment:
name: ${{ matrix.environment }}
url: ${{ steps.deploy.outputs.environment_url }}
Expand Down

0 comments on commit 25e0814

Please sign in to comment.