Last active
May 10, 2022 15:40
-
-
Save creachadair/e5127066073ff8b03fbdb977eb404ef4 to your computer and use it in GitHub Desktop.
A script to retry a failed GitHub actions run.
This file contains hidden or 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
#!/bin/zsh | |
set -euo pipefail | |
readonly pollsec=5 | |
if [[ "$#" = 0 ]] ; then | |
echo "Missing required run ID" 1>&2 | |
exit 2 | |
fi | |
runjob() { | |
local id="${1:?missing ID}" | |
while ! gh run watch -i "$pollsec" --exit-status "$id" ; do | |
voicenote Run failed, retrying. | |
sleep 1 | |
gh run rerun --failed "$id" | |
sleep 1 | |
done | |
voicenote Run finished successfully. | |
} | |
trap 'wait' EXIT | |
for id in "$@" ; do | |
runjob "$id" & | |
done | |
echo "Waiting for $# jobs to complete..." 1>&2 |
This file contains hidden or 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
#!/bin/bash | |
set -euo pipefail | |
readonly here="$(dirname $0)" | |
readonly match='(Test|e2e)' | |
readonly branch="${1:?missing branch name}" | |
gh run list --limit=200 --json conclusion,name,databaseId,status,headBranch \ | |
| jq ' | |
.[] | |
| select(.headBranch=="'"${branch}"'") | |
| [ select(.name=="e2e") | |
| select(.conclusion=="" or .conclusion=="failure")][:1] + | |
[ select(.name=="Test") | |
| select(.conclusion=="" or .conclusion=="failure")][:1] | |
| .[] | .databaseId' \ | |
| xargs -t "${here}"/gh-run.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment