A Node.js CLI tool to download GitHub Actions logs for CI workflows. This is a port of the Ruby Rake task to JavaScript/Node.js.
- Download
fetch-ci-logs.jsandpackage.jsonto your project - Install dependencies:
npm install
Or install globally:
npm install -g .# Download logs for the latest CI run
node fetch-ci-logs.js fetch-logs
# Download logs for a specific workflow
node fetch-ci-logs.js fetch-logs ci.yml
# Download logs for a specific run ID
node fetch-ci-logs.js fetch-logs ci.yml 123456789
# Download logs for a specific repository
node fetch-ci-logs.js fetch-logs ci.yml 123456789 myorg/myrepo
# Push current branch then wait for CI and download logs
node fetch-ci-logs.js after-push
# Push to a specific remote and branch
node fetch-ci-logs.js after-push upstream feature-branch{
"scripts": {
"ci:fetch-logs": "node fetch-ci-logs.js fetch-logs",
"ci:after-push": "node fetch-ci-logs.js after-push"
}
}Then use:
npm run ci:fetch-logs
npm run ci:after-push| Variable | Description | Default |
|---|---|---|
GITHUB_TOKEN |
GitHub personal access token | Required |
GITHUB_REPO |
Repository in "owner/repo" format | Auto-detected |
CI_WORKFLOW |
Workflow file name | ci.yml |
RUN_ID |
Specific run ID to download | Latest run |
WAIT / WAIT_FOR_RUN |
Wait for workflow run to appear | false |
WAIT_FOR_COMPLETION |
Wait for run to complete | false |
WAIT_TIMEOUT |
Timeout in seconds | 300 |
WAIT_INTERVAL |
Polling interval in seconds | 5 |
SKIP_PUSH |
Skip git push in after-push | false |
# Set your GitHub token
export GITHUB_TOKEN=your_github_token_here
# Download latest CI logs
node fetch-ci-logs.js fetch-logs
# Download logs for a specific repository
GITHUB_REPO=myorg/myrepo node fetch-ci-logs.js fetch-logs# Wait for CI to complete and download logs
WAIT_FOR_COMPLETION=1 node fetch-ci-logs.js fetch-logs
# Download logs for a specific workflow with custom timeout
CI_WORKFLOW=deploy.yml WAIT_TIMEOUT=600 node fetch-ci-logs.js fetch-logs
# Push and wait for CI (useful for CI/CD pipelines)
node fetch-ci-logs.js after-pushAdd to your GitHub Actions workflow:
- name: Download CI Logs
run: node fetch-ci-logs.js fetch-logs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}The tool creates a directory structure like:
log/ci/
└── 123456789-abc1234/
├── run_123456789.zip # Combined run logs
├── run_123456789_metadata.json # Run metadata
├── job_987654321_test.log # Individual job logs
└── job_987654322_build.log
- CLI Interface: Uses command-line arguments instead of Rake task arguments
- Dependencies: Uses
axiosinstead offaraday - Async/Await: Fully async instead of synchronous operations
- Error Handling: More robust error handling with try/catch
- File Operations: Uses Node.js
fs.promisesAPI - Git Operations: Uses
child_process.execSyncinstead of Ruby backticks
- Node.js 14+
- npm
- Git
- GitHub personal access token with Actions read permissions
MIT