Skip to content

Commit

Permalink
Merge pull request #4 from mcpengelly/prevent-cancelling-other-workflows
Browse files Browse the repository at this point in the history
Add the ability to set a REVIEWERS_UNMODIFIED_EXIT_CODE, avoiding parallel action cancellation
  • Loading branch information
Abi Noda authored Jun 17, 2019
2 parents 1eac22d + 38e3671 commit 3e8e4c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ action "Assignee to reviewer" {
secrets = [
"GITHUB_TOKEN"
]
# add this line if you want to continue running parrallel github actions even if this action is skipped/not needed
env = {
REVIEWERS_UNMODIFIED_EXIT_CODE = "0"
}
}
}
```

Expand Down
10 changes: 8 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ action=$(jq --raw-output .action "$GITHUB_EVENT_PATH")
number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
assignee=$(jq --raw-output .assignee.login "$GITHUB_EVENT_PATH")

# Github Actions will mark a check as "neutral" (neither failed/succeeded) when you exit with code 78
# But this will terminate any other Actions running in parallel in the same workflow.
# Configuring this Environment Variable `REVIEWERS_UNMODIFIED_EXIT_CODE=0` if no branch was deleted will let your workflow continue.
# Docs: https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#exit-codes-and-statuses
REVIEWERS_UNMODIFIED_EXIT_CODE=${REVIEWERS_UNMODIFIED_EXIT_CODE:-78}

update_review_request() {
curl -sSL \
-H "Content-Type: application/json" \
Expand All @@ -39,5 +45,5 @@ elif [[ "$action" == "unassigned" ]]; then
update_review_request 'DELETE'
else
echo "Ignoring action ${action}"
exit 78
fi
exit "$REVIEWERS_UNMODIFIED_EXIT_CODE"
fi

0 comments on commit 3e8e4c7

Please sign in to comment.