Skip to content

Commit

Permalink
fix: workflow now cancels itself when newer workflow is detected (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustaphazorgati authored Mar 30, 2021
1 parent 11ce1a2 commit 70016f4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ function convertToKeyValuePairs() {
}

function getRunningWorkflowIds() {
jq ".workflow_runs | .[] | select(.head_branch==\"${branch?}\" and .head_repository.full_name==\"${repo?}\" and .status==\"in_progress\" or .status==\"queued\" or .status== \"waiting\") | .id " | grep -v "${GITHUB_RUN_ID}" || :
local workflow_ids
workflow_ids=$(jq ".workflow_runs | .[] | select(.head_branch==\"${branch?}\" and .head_repository.full_name==\"${repo?}\" and .status==\"in_progress\" or .status==\"queued\" or .status== \"waiting\") | .id ")
local condition="<"
for id in $workflow_ids; do
if [[ "$id" -gt "$GITHUB_RUN_ID" ]]; then
condition="<="
break
fi
done
echo "$workflow_ids" | jq "select( . $condition $GITHUB_RUN_ID )"
}

function exportAll() {
Expand Down

0 comments on commit 70016f4

Please sign in to comment.