Skip to content

Commit

Permalink
cancel workflow if another one is running
Browse files Browse the repository at this point in the history
  • Loading branch information
ivvist committed Apr 28, 2024
1 parent 50212a1 commit cdaa1df
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/cancelworkflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ while IFS= read -r line; do
fi
done < <(gh run list -b "${br}" --workflow "${wf}" --limit 3 -e pull_request_target -s in_progress --json 'databaseId' --jq '.[] | .databaseId' -R "${rp}")

if [ "${#workflows[@]}" -le 2 ]; then
exit 0
fi
# Output the results
for workflow in "${workflows[@]}"; do
for workflow in "${workflows[@]:1}"; do
echo "Running workflow: $workflow. Trying to cancel..."
gh run cancel $workflow || true
done

0 comments on commit cdaa1df

Please sign in to comment.