diff --git a/.github/workflows/staging-build-pr.yml b/.github/workflows/staging-build-pr.yml index 9263188b3644..5d4f9707435f 100644 --- a/.github/workflows/staging-build-pr.yml +++ b/.github/workflows/staging-build-pr.yml @@ -14,6 +14,11 @@ on: permissions: contents: read +# This allows one Build workflow run to interrupt another +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label }}' + cancel-in-progress: true + jobs: debug: runs-on: ubuntu-latest @@ -27,8 +32,10 @@ jobs: if: ${{ github.repository == 'github/docs-internal' || github.repository == 'github/docs' }} runs-on: ubuntu-latest timeout-minutes: 5 + # This interrupts Build, Deploy, and pre-write Undeploy workflow runs in + # progress for this PR branch. concurrency: - group: staging_${{ github.head_ref }} + group: 'PR Staging @ ${{ github.event.pull_request.head.label }}' cancel-in-progress: true steps: - name: Check out repo diff --git a/.github/workflows/staging-deploy-pr.yml b/.github/workflows/staging-deploy-pr.yml index 7e59ff4c2b08..1b7f65236cc3 100644 --- a/.github/workflows/staging-deploy-pr.yml +++ b/.github/workflows/staging-deploy-pr.yml @@ -18,6 +18,15 @@ permissions: pull-requests: read statuses: write +# IMPORTANT: Intentionally OMIT a `concurrency` configuration from this workflow's +# top-level as we do not have any guarantee of identifying values being available +# within the `github.event` context for PRs from forked repos! +# +# The implication of this shortcoming is that we may have multiple workflow runs +# of this running at the same time for different commits within the same PR. +# However, once they reach the `concurrency` configurations deeper down within +# this workflow's jobs, then we can expect concurrent short-circuiting to begin. + env: CONTEXT_NAME: '${{ github.workflow }} / deploy (${{ github.event.workflow_run.event }})' ACTIONS_RUN_LOG: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -184,8 +193,10 @@ jobs: }} runs-on: ubuntu-latest timeout-minutes: 1 + # This interrupts Build, Deploy, and pre-write Undeploy workflow runs in + # progress for this PR branch. concurrency: - group: 'staging_${{ needs.pr-metadata.outputs.head_ref }}' + group: 'PR Staging @ ${{ needs.pr-metadata.outputs.head_label }}' cancel-in-progress: true outputs: pull_request_state: ${{ steps.check-pr.outputs.state }} @@ -210,8 +221,10 @@ jobs: if: ${{ needs.check-pr-before-prepare.outputs.pull_request_state == 'open' }} runs-on: ubuntu-latest timeout-minutes: 5 + # This interrupts Build, Deploy, and pre-write Undeploy workflow runs in + # progress for this PR branch. concurrency: - group: 'staging_${{ needs.pr-metadata.outputs.head_ref }}' + group: 'PR Staging @ ${{ needs.pr-metadata.outputs.head_label }}' cancel-in-progress: true outputs: source_blob_url: ${{ steps.build-source.outputs.download_url }} @@ -374,8 +387,10 @@ jobs: needs: [pr-metadata, prepare-for-deploy] runs-on: ubuntu-latest timeout-minutes: 1 + # This interrupts Build, Deploy, and pre-write Undeploy workflow runs in + # progress for this PR branch. concurrency: - group: 'staging_${{ needs.pr-metadata.outputs.head_ref }}' + group: 'PR Staging @ ${{ needs.pr-metadata.outputs.head_label }}' cancel-in-progress: true outputs: pull_request_state: ${{ steps.check-pr.outputs.state }} @@ -400,8 +415,10 @@ jobs: if: ${{ needs.check-pr-before-deploy.outputs.pull_request_state == 'open' }} runs-on: ubuntu-latest timeout-minutes: 10 + # This interrupts Build, Deploy, and pre-write Undeploy workflow runs in + # progress for this PR branch. concurrency: - group: 'staging_${{ needs.pr-metadata.outputs.head_ref }}' + group: 'PR Staging @ ${{ needs.pr-metadata.outputs.head_label }}' cancel-in-progress: true steps: - name: Check out repo's default branch diff --git a/.github/workflows/staging-undeploy-pr.yml b/.github/workflows/staging-undeploy-pr.yml index 39d6957628b1..cdbcf6593dba 100644 --- a/.github/workflows/staging-undeploy-pr.yml +++ b/.github/workflows/staging-undeploy-pr.yml @@ -13,6 +13,11 @@ permissions: contents: read deployments: write +# This prevents one Undeploy workflow run from interrupting another +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label }}' + cancel-in-progress: false + jobs: debug: runs-on: ubuntu-latest @@ -22,14 +27,25 @@ jobs: GITHUB_CONTEXT: ${{ toJSON(github) }} run: echo "$GITHUB_CONTEXT" - undeploy: + cancel-jobs-before-undeploy: if: ${{ github.repository == 'github/docs-internal' || github.repository == 'github/docs' }} - name: Undeploy runs-on: ubuntu-latest - timeout-minutes: 2 + # This interrupts Build and Deploy workflow runs in progress for this PR + # branch. However, it does so with an intentionally short, independent job + # so that the following `undeploy` job cannot be cancelled once started! concurrency: - group: staging_${{ github.head_ref }} + group: 'PR Staging @ ${{ github.event.pull_request.head.label }}' cancel-in-progress: true + steps: + - name: Cancelling other deployments via concurrency configuration + run: | + echo 'Cancelling other deployment runs (if any)...' + + undeploy: + if: ${{ github.repository == 'github/docs-internal' || github.repository == 'github/docs' }} + runs-on: ubuntu-latest + timeout-minutes: 2 + # IMPORTANT: Intentionally OMIT a `concurrency` configuration from this job! steps: - name: Check out repo's default branch uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f