-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script and using it in pull requests workflow that is used to eva…
…luate the result of the jobs that a job depends on (`needs`)
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script is used to evaluate the result of the jobs that a job depends on (`needs`). | ||
# | ||
# The script expects a string containing the JSON of the `needs` as a parameter. Example invocation: | ||
# `./exit-1-if-result-failure-was-passed.sh "{ e2e_tests: { result: failure, outputs: {} } }"` | ||
# If one of the `needs` had the result "failure", the script exits with 1. Otherwise, it exits with 0. | ||
|
||
# Assign the parameters to constants to improve readability. | ||
NEEDS_JSON="$1" | ||
|
||
# Echo the passed JSON for easier debugging | ||
echo "Evaluating the following JSON for failures:" | ||
echo "$NEEDS_JSON" | ||
|
||
if echo "$NEEDS_JSON" | grep -q "result: failure"; then | ||
echo "One or more jobs seem to have failed." | ||
exit 1 | ||
elif echo "$NEEDS_JSON" | grep -q "result: skipped"; then | ||
echo "One or more jobs seem to have been skipped." | ||
exit 1 | ||
else | ||
echo "Looks like all jobs succeeded." | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters