docs: add AGENTS.md and improve documentation discoverability #175
Workflow file for this run
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: Cancel PR Workflows on Close | |
| on: | |
| pull_request: | |
| types: [ closed ] | |
| permissions: | |
| actions: write | |
| jobs: | |
| cancel: | |
| name: Cancel In-Progress Workflows | |
| if: github.event.pull_request.merged == false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Cancel PR Build and Integration Tests | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const workflows = [ | |
| 'pr-build.yml', | |
| 'codeql.yml', | |
| 'integration-test-single-node.yml', | |
| 'integration-test-multinode.yml', | |
| ]; | |
| const headSha = context.payload.pull_request.head.sha; | |
| const prNumber = context.payload.pull_request.number; | |
| for (const workflowId of workflows) { | |
| // Wrap each workflow iteration so a missing / renamed file | |
| // doesn't take down the whole cancel job — other workflows | |
| // in the list still get processed. | |
| try { | |
| for (const status of ['in_progress', 'queued']) { | |
| const runs = await github.paginate( | |
| github.rest.actions.listWorkflowRuns, | |
| { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: workflowId, | |
| status, | |
| event: 'pull_request', | |
| per_page: 100, | |
| }, | |
| (response) => response.data.workflow_runs | |
| ); | |
| for (const run of runs) { | |
| if (!run) { | |
| continue; | |
| } | |
| const prs = Array.isArray(run.pull_requests) ? run.pull_requests : []; | |
| const isTargetPr = prs.length === 0 || prs.some((pr) => pr.number === prNumber); | |
| if (run.head_sha === headSha && isTargetPr) { | |
| await github.rest.actions.cancelWorkflowRun({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: run.id, | |
| }); | |
| console.log(`Cancelled ${workflowId} run #${run.id} (${status})`); | |
| } | |
| } | |
| } | |
| } catch (err) { | |
| console.log(`Skipping ${workflowId}: ${err.message}`); | |
| } | |
| } |