entry-pr-closed-cancel-workflows.ymlΒΆ

name: "🚫 Cancel: PR Runs on Close"

on:
  pull_request_target:
    types:
      - closed
      - converted_to_draft

concurrency:
  group: pr-ci-${{ github.repository }}-pull_request-pr-${{ github.event.pull_request.number }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  cancel-pr-runs:
    runs-on: ubuntu-26.04
    permissions:
      actions: write
      contents: read
      pull-requests: read
    steps:
      - name: ⬇️ Checkout
        uses: actions/checkout@v7.0.0

      - name: 🚫 Cancel active workflow runs for closed PR
        shell: bash
        env:
          PR_NUMBER: ${{ github.event.pull_request.number }}
          PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
          PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
          PR_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          REPOSITORY: ${{ github.repository }}
          CURRENT_RUN_ID: ${{ github.run_id }}
        run: bash scripts/github/cancel/pull_request_runs.sh