Skip to content

Instantly share code, notes, and snippets.

@jsoref
Created December 19, 2023 22:40
Show Gist options
  • Save jsoref/22df690ce9e1be7ff86534278fab6140 to your computer and use it in GitHub Desktop.
Save jsoref/22df690ce9e1be7ff86534278fab6140 to your computer and use it in GitHub Desktop.
Get github repository workflow run logs
gh_collect_repo_workflow_logs() {
OWNER="$1"
REPO="$2"
for workflow_run in $(gh api "/repos/$OWNER/$REPO/actions/runs" |jq -r -M '.workflow_runs[].id'); do
for job in $(
gh api "/repos/$OWNER/$REPO/actions/runs/$workflow_run/jobs" | jq '.jobs[].id'
); do
gh run view -R "$OWNER/$REPO" --log -j $job > "$workflow_run.$job.log"
done
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment