diff --git a/.github/workflows/pr_closed.yaml b/.github/workflows/pr_closed.yaml new file mode 100644 index 0000000..506a375 --- /dev/null +++ b/.github/workflows/pr_closed.yaml @@ -0,0 +1,56 @@ +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 wor§kflow 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 + if: needs.check-merge-or-workflow-dispatch.outputs.deploy == 'true' + + permissions: + id-token: write + contents: read + + strategy: + max-parallel: 1 + matrix: + component: [acct, cdn] + + uses: ./.github/workflows/reusable_internal_repo_build.yaml + secrets: inherit + with: + release_version: main + target_workflow: "dispatch-deploy-static-notify-web-gateway.yaml" + tf_environment: "main" + tf_group: "nhs-notify-web-dev" + tf_component: ${{ matrix.component }} + tf_action: "apply" diff --git a/.github/workflows/pr_merge.yaml b/.github/workflows/pr_merge.yaml deleted file mode 100644 index d3f474d..0000000 --- a/.github/workflows/pr_merge.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: PR Merged - -on: - workflow_dispatch: - pull_request: - types: [closed] - branches: - - main - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false - -jobs: - deploy-main: - name: Deploy changes to main - - permissions: - id-token: write - contents: read - - strategy: - max-parallel: 1 - matrix: - component: [acct, cdn] - - uses: ./.github/workflows/reusable_internal_repo_build.yaml - secrets: inherit - with: - release_version: main - target_workflow: "dispatch-deploy-static-notify-web-gateway.yaml" - tf_environment: "main" - tf_group: "nhs-notify-web-dev" - tf_component: ${{ matrix.component }} - tf_action: "apply"