fix: [6570595001] Add correct error handling logic. #3760
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 Workflow on Merge | |
| on: | |
| pull_request: | |
| types: [closed] | |
| jobs: | |
| cancel-workflow: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: write | |
| steps: | |
| - name: Cancel Workflow if Merged or Closed | |
| if: ${{ github.event.pull_request.merged || github.event.pull_request.state == 'closed' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "PR has been merged or closed, cancelling workflow..." | |
| gh auth status | |
| gh run list \ | |
| --repo ${{ github.repository }} \ | |
| --branch ${{ github.event.pull_request.head.ref }} \ | |
| --workflow "TDengine Test" \ | |
| --json databaseId,name,status \ | |
| --jq '.[] | select(.status == "in_progress" or .status == "queued") | .databaseId ' | \ | |
| xargs -I {} gh run cancel --repo ${{ github.repository }} {} |