Fetch Action Logs

Fetch and display logs for a GitHub Actions run. Use when the user asks to get, check, or view CI logs for a GitHub Actions run. Use when this capability is needed.

tomevault-io 3e4e953 2 files · 2.0 KB Updated

File contents

Fetch GitHub Actions Run Logs

Finding the run ID

If no run ID is provided, list recent runs:

gh run list --limit 5

The run ID is the numeric ID in the output (second to last column).

Downloading logs

REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)

curl -L \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "Accept: application/vnd.github+json" \
  "https://api.github.com/repos/$REPO/actions/runs/<RUN_ID>/logs" \
  -o /tmp/gh_logs.zip

Extracting and displaying logs

rm -rf /tmp/gh_logs && unzip -o /tmp/gh_logs.zip -d /tmp/gh_logs/

Then read the relevant log files from /tmp/gh_logs/ to show the user what happened.

Getting logs for a specific job

curl -L \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "Accept: application/vnd.github+json" \
  "https://api.github.com/repos/$REPO/actions/jobs/<JOB_ID>/logs" \
  -o /tmp/gh_job.log

The job endpoint returns plain text instead of a zip.


Source: finbarrtimbers/llamax — distributed by TomeVault.

tomevault-io/skills-registry/tree/main/finbarrtimbers--llamax--fetch-action-logs commit 3e4e9535c9

Frequently asked questions

npx skillmds@latest add tomevault-io/fetch-action-logs