#!/usr/bin/env bash # Saves the CI part of the video from GitHub: the workflow of bino-bi/kestrel-report (private), # pull request 1 (the change, green, reviewed, merged) and pull request 2 (the typo, red). # ./ci.sh needs gh with access to bino-bi/kestrel-report set -euo pipefail cd "$(dirname "$0")" REPO=bino-bi/kestrel-report OUT=ci rm -rf "$OUT"; mkdir -p "$OUT" gh api "repos/$REPO/contents/.github/workflows/report.yml" -q .content | base64 -d > "$OUT/report.yml" for n in 1 2; do gh pr view "$n" -R "$REPO" --json number,title,state,headRefName,additions,deletions,changedFiles,commits,reviews,mergedAt > "$OUT/pr-$n.json" run=$(gh run list -R "$REPO" -b "$(gh pr view "$n" -R "$REPO" --json headRefName -q .headRefName)" -e pull_request -L 1 --json databaseId -q '.[0].databaseId') gh api "repos/$REPO/actions/runs/$run/jobs" -q '.jobs[0] | {conclusion, steps: [.steps[] | {name, conclusion, started_at, completed_at}]}' > "$OUT/run-$n.json" gh api "repos/$REPO/actions/runs/$run/artifacts" -q '[.artifacts[] | {name, size_in_bytes}]' > "$OUT/artifacts-$n.json" done gh api "repos/$REPO/pulls/1/comments" -q '[.[] | {path, line, body}]' > "$OUT/review-1.json" run2=$(gh run list -R "$REPO" -b fix-plan-column -e pull_request -L 1 --json databaseId -q '.[0].databaseId') gh run view "$run2" -R "$REPO" --log-failed | perl -pe 's/^.*?Z //; s/(\e|\^\[)\[[0-9;]*m//g' | grep -v '^\s*$' > "$OUT/fail-2.log" ls "$OUT"