Skip to content

Commit ab68807

Browse files
ci: Fix unknown flag --pr error in manual workflow cancellation script
1 parent d876a89 commit ab68807

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

.github/workflows/cancel-workflows.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ jobs:
5454
run: |
5555
echo "Cancelling runs for PR #$PR_NUMBER..."
5656
57-
# Get all runs for the PR that are NOT completed, excluding this current run
58-
RUN_IDS=$(gh run list --pr "$PR_NUMBER" --limit 200 --json databaseId,status --jq '.[] | select(.status != "completed" and .databaseId != (env.CURRENT_RUN_ID | tonumber)) | .databaseId')
57+
# gh run list doesn't have a --pr flag, so we get the branch name first
58+
PR_BRANCH=$(gh pr view "$PR_NUMBER" --json headRefName -q .headRefName)
59+
60+
# Get all runs for the PR branch that are NOT completed, excluding this current run
61+
RUN_IDS=$(gh run list --branch "$PR_BRANCH" --limit 200 --json databaseId,status --jq '.[] | select(.status != "completed" and .databaseId != (env.CURRENT_RUN_ID | tonumber)) | .databaseId')
5962
6063
if [ -z "$RUN_IDS" ]; then
6164
echo "No active runs found to cancel."

0 commit comments

Comments
 (0)