Skip to content

Instantly share code, notes, and snippets.

@amotl
Last active December 7, 2024 05:07
Show Gist options
  • Save amotl/d7de8de01eafba602dd9c6bfa9cfac6d to your computer and use it in GitHub Desktop.
Save amotl/d7de8de01eafba602dd9c6bfa9cfac6d to your computer and use it in GitHub Desktop.
Enumerate recent build failures in repositories relevant for CrateDB's ecosystem
# GitHub Actions Workflow Failures Digest for CrateDB's ecosystem
# https://github.com/crate/crate-clients-tools/issues/148
# Optionally use authentication when running into rate limits.
# It is an (here invalidated) personal access token (classic),
# using the "workflow" scope.
# GITHUB_TOKEN=ghp_00r4G0tGxLDT5RGOwWNw7tZhFnK5fT0uMfoo
# HTTPIE_OPTIONS="--auth-type bearer --auth ${GITHUB_TOKEN}"
# Prefer to use `gdate` on macOS.
date=date
if command -v sw_vers; then
date=gdate
fi
# GitHub repository names from Build Status Markdown.
function build-status-gh-repos() {
http --follow https://github.com/crate/crate-clients-tools/raw/refs/heads/main/docs/status.md | \
grep "github.com.*yml" | perl -pe 's#.*github\.com/(.+?)/(.+?)/.*#\1/\2#' | sort | uniq
}
# GHA workflow status (per-repository).
function gha-failures() {
repo="$1"
http ${HTTPIE_OPTIONS} https://api.github.com/repos/${repo}/actions/runs \
event==schedule status==failure "created==:>=$(${date} -d 'yesterday' '+%Y-%m-%d')" | \
jq '[ .workflow_runs[] | {name, display_title, path, html_url, status, conclusion, created_at} ]'
}
# Enumerate all repositories, and check for GHA workflow failures.
function main() {
for repo in $(build-status-gh-repos); do
echo "Repository: ${repo}"
gha-failures ${repo}
done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment