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:
commit
d7a4fa7601
4
.github/workflows/build-shit.yml
vendored
4
.github/workflows/build-shit.yml
vendored
|
@ -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]
|
||||
|
|
35
.github/workflows/cancel-merged-branches.yml
vendored
Normal file
35
.github/workflows/cancel-merged-branches.yml
vendored
Normal 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
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue