ci: update workflow to cancel on pull request close in addition to merge

This commit is contained in:
chenhaoran 2025-03-12 20:58:05 +08:00
parent a894601907
commit 4adee83552
1 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
name: Cancel Workflow on Merge name: Cancel Workflow on Merge or Close
on: on:
pull_request: pull_request:
@ -8,8 +8,8 @@ jobs:
cancel-workflow: cancel-workflow:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Cancel Workflow if Merged - name: Cancel Workflow if Merged or Closed
if: ${{ github.event.pull_request.merged }} if: ${{ github.event.pull_request.merged || github.event.pull_request.state == 'closed' }}
run: | run: |
echo "PR has been merged, cancelling workflow..." echo "PR has been merged or closed, cancelling workflow..."
gh run cancel --repo ${{ github.repository }} --workflow "TDengine Test" --branch ${{ github.event.pull_request.base.ref }} gh run list --repo ${{ github.repository }} --branch ${{ github.event.pull_request.head.ref }} --workflow "TDengine Test" --status in_progress --json databaseId --jq '.[].databaseId' | xargs -I {} gh run cancel {}