diff --git a/.github/workflows/build-shit.yml b/.github/workflows/build-shit.yml index e217d1f18..4d674f025 100644 --- a/.github/workflows/build-shit.yml +++ b/.github/workflows/build-shit.yml @@ -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] diff --git a/.github/workflows/cancel-merged-branches.yml b/.github/workflows/cancel-merged-branches.yml new file mode 100644 index 000000000..b9b66834b --- /dev/null +++ b/.github/workflows/cancel-merged-branches.yml @@ -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 + }); + });