1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-05 06:14:36 +00:00

Merge pull request #443 from FunkinCrew/cancel-merged-actions

Cancel runs of merged and "outdated" branches
This commit is contained in:
Cameron Taylor 2024-03-29 01:46:01 -04:00
commit d7a4fa7601
2 changed files with 39 additions and 0 deletions

View file

@ -3,6 +3,10 @@ on:
workflow_dispatch:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
create-nightly-html5:
runs-on: [self-hosted, linux]

View file

@ -0,0 +1,35 @@
name: cancel-merged-branches
on:
pull_request:
types:
- closed
push:
jobs:
cancel_stuff:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: actions/github-script@v7
id: cancel-runs
with:
result-encoding: string
retries: 3
script: |
let branch_workflows = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "build-shit.yml",
status: "queued",
branch: "${{ github.ref_name }}"
});
let runs = branch_workflows.data.workflow_runs;
runs.forEach((run) => {
github.rest.actions.cancelWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run.id
});
});