ci: enhance workflow to set up GitHub CLI and cancel on PR merge or close
This commit is contained in:
parent
4adee83552
commit
ad7afcc437
|
@ -8,8 +8,15 @@ jobs:
|
||||||
cancel-workflow:
|
cancel-workflow:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set up GitHub CLI
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.GITHUB_TOKEN }}" > ~/.gh_token
|
||||||
|
gh auth login --with-token < ~/.gh_token
|
||||||
|
|
||||||
- name: Cancel Workflow if Merged or Closed
|
- name: Cancel Workflow if Merged or Closed
|
||||||
if: ${{ github.event.pull_request.merged || github.event.pull_request.state == 'closed' }}
|
if: ${{ github.event.pull_request.merged || github.event.pull_request.state == 'closed' }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
echo "PR has been merged or closed, cancelling workflow..."
|
echo "PR has been merged or closed, cancelling workflow..."
|
||||||
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 {}
|
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 {}
|
Loading…
Reference in New Issue