Feature/sandbox testing #121
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Closed | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| check-merge-or-workflow-dispatch: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| deploy: ${{ steps.check.outputs.deploy }} | |
| steps: | |
| - name: Check if PR was merged or workflow is triggered by workflow_dispatch | |
| id: check | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "deploy=true" >> $GITHUB_OUTPUT | |
| echo "Job triggered by workflow_dispatch - running 'deploy-main'" | |
| elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.merged }}" == "true" ]]; then | |
| echo "deploy=true" >> $GITHUB_OUTPUT | |
| echo "Job triggered by Merged PR - running 'deploy-main'" | |
| else | |
| echo "deploy=false" >> $GITHUB_OUTPUT | |
| echo "Job not triggered by workflow_dispatch or Merged PR - Skipping 'deploy-main'" | |
| fi | |
| deploy-main: | |
| needs: check-merge-or-workflow-dispatch | |
| name: Deploy changes to main in dev AWS account | |
| runs-on: ubuntu-latest | |
| if: needs.check-merge-or-workflow-dispatch.outputs.deploy == 'true' | |
| permissions: | |
| id-token: write | |
| contents: read | |
| strategy: | |
| max-parallel: 1 | |
| matrix: | |
| component: [api] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Updating Main Environment | |
| env: | |
| APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }} | |
| APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }} | |
| run: | | |
| bash .github/scripts/dispatch_internal_repo_workflow.sh \ | |
| --releaseVersion "main" \ | |
| --targetWorkflow "dispatch-deploy-static-notify-supplier-api-env.yaml" \ | |
| --targetEnvironment "main" \ | |
| --targetAccountGroup "nhs-notify-supplier-api-dev" \ | |
| --targetComponent "${{ matrix.component }}" \ | |
| --terraformAction "apply" |