Skip to content

Instantly share code, notes, and snippets.

@fffergal
Created December 15, 2023 11:59
Show Gist options
  • Save fffergal/59d33000f50e9d78dfcba0b768554162 to your computer and use it in GitHub Desktop.
Save fffergal/59d33000f50e9d78dfcba0b768554162 to your computer and use it in GitHub Desktop.
A little script to send you a notification when the main branch build finishes.
#!/usr/bin/env bash
set -euo pipefail
repo="$(gh repo view --json nameWithOwner | jq -r .nameWithOwner)"
default_branch="$(gh repo view --json defaultBranchRef | jq -r .defaultBranchRef.name)"
status="$(gh api "/repos/$repo/commits/$default_branch/status" --jq '.state')"
while [[ "$status" = "pending" ]] ; do
sleep 60
status="$(gh api "/repos/$repo/commits/$default_branch/status" --jq '.state')"
done
osascript -e 'display notification "'"$repo"' '"$default_branch"' status is '"$status"'"'
if [[ "$status" != "success" ]] ; then
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment