Skip to content

Instantly share code, notes, and snippets.

@macrael
Last active December 16, 2021 23:37
Show Gist options
  • Select an option

  • Save macrael/aac6775586cf2449d37e329001fdcd69 to your computer and use it in GitHub Desktop.

Select an option

Save macrael/aac6775586cf2449d37e329001fdcd69 to your computer and use it in GitHub Desktop.
This script watches the currently running github action for the current branch and `say`s "Github action run complete" when it finishes.
#!/bin/bash
# Get Branch Name
branch_name=$(git rev-parse --abbrev-ref HEAD)
# Filter Running Actions
run_line=$(gh run list | grep "$branch_name" | grep "in_progress" | head -n 1)
if [ -z "$run_line" ]; then
echo "No active GH action run found for the current branch"
exit 1
fi
# Parse out run id
run_id=$(echo "$run_line" | awk '{print $(NF - 2)}')
# Watch that
gh run watch "$run_id"
# say something
say "Github action run complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment