Created
August 6, 2025 22:37
-
-
Save nateberkopec/900ce988d8c6b2d25d500377e61399bc to your computer and use it in GitHub Desktop.
Watch GitHub PR status with audio notifications
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 -e | |
if [ $# -eq 0 ]; then | |
echo "Usage: gh_watch <github-pr-url>" | |
echo "Example: gh_watch https://github.com/hyfn/xpo/pull/4974" | |
exit 1 | |
fi | |
url="$1" | |
if [[ ! "$url" =~ github\.com/.+/pull/[0-9]+ ]]; then | |
echo "Error: Invalid GitHub PR URL format" | |
echo "Expected format: https://github.com/owner/repo/pull/number" | |
exit 1 | |
fi | |
repo_path=$(echo "$url" | sed -n 's|.*github\.com/\([^/]*/[^/]*\)/pull/.*|\1|p') | |
pr_number=$(echo "$url" | sed -n 's|.*/pull/\([0-9]*\).*|\1|p') | |
if [ -z "$repo_path" ] || [ -z "$pr_number" ]; then | |
echo "Error: Could not parse repository and PR number from URL" | |
exit 1 | |
fi | |
silent_exit=false | |
cleanup() { | |
silent_exit=true | |
exit 0 | |
} | |
trap cleanup SIGINT SIGTERM | |
echo "Watching PR #$pr_number in $repo_path..." | |
gh pr checks "$pr_number" --repo "$repo_path" --watch | |
exit_code=$? | |
if [ "$silent_exit" = false ]; then | |
if [ $exit_code -eq 0 ]; then | |
say "Build succeeded for PR $pr_number" | |
else | |
say "Build failed for PR $pr_number" | |
fi | |
fi | |
exit $exit_code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment