| name | workflow |
| description | Manage GitHub Actions workflows using gh CLI. Use to check CI status, view run logs, analyze failures, and rerun workflows. |
GitHub Actions Workflow Manager
Monitor and manage CI/CD workflows using the GitHub CLI.
Prerequisites
Install GitHub CLI:
brew install gh
curl -sS https://webi.sh/gh | sh
Authenticate:
gh auth login
CLI Reference
Quick Status Check
gh run list --branch $(git branch --show-current) --limit 5
gh run list --limit 10
gh run list --workflow "CI" --limit 5
View Specific Run
gh run view <run-id>
gh run view <run-id> --log
gh run view <run-id> --log-failed
gh run view <run-id> --exit-status
List Runs with Filters
gh run list --branch main --limit 10
gh run list --workflow "Build and Test" --limit 10
gh run list --status failure --limit 10
gh run list --status success --limit 10
gh run list --status in_progress --limit 10
gh run list --branch main --workflow "CI" --status failure --limit 5
Rerun Workflows
gh run rerun <run-id>
gh run rerun <run-id> --failed
gh run rerun <run-id> --job <job-id>
Watch Running Workflow
gh run watch <run-id>
gh run watch <run-id> --exit-status
Download Artifacts
gh run view <run-id> --json artifacts
gh run download <run-id>
gh run download <run-id> --name "artifact-name"
gh run download <run-id> --dir ./artifacts
Cancel a Run
gh run cancel <run-id>
View Workflow Files
gh workflow list
gh workflow view "CI"
gh workflow enable "CI"
gh workflow disable "CI"
Run Workflow Manually
gh workflow run "CI"
gh workflow run "Deploy" -f environment=staging -f version=1.2.3
gh workflow run "CI" --ref feature-branch
Output Formats
gh run list --json status,conclusion,name,headBranch,url
gh run view <run-id> --json jobs,status,conclusion
Workflow Patterns
Quick CI Check
gh run list --branch $(git branch --show-current) --limit 1 --json status,conclusion
Debug Failing CI
gh run list --branch main --status failure --limit 1
gh run view <run-id> --log-failed
gh run rerun <run-id> --failed
Monitor Deployment
gh run watch <run-id>
gh run watch <run-id> && osascript -e 'display notification "Deployment complete"'
Retry Flaky Tests
gh run rerun <run-id> --failed
Pre-Merge Check
gh run list --branch $(git branch --show-current) --json conclusion --jq '.[0].conclusion'
Common Statuses
| Status | Meaning |
|---|
queued | Waiting to start |
in_progress | Currently running |
completed | Finished |
| Conclusion | Meaning |
|---|
success | All jobs passed |
failure | One or more jobs failed |
cancelled | Run was cancelled |
skipped | Run was skipped |
timed_out | Run exceeded time limit |
Best Practices
- Check status before merge - Ensure CI passes
- Use
--log-failed - Only see relevant failure logs
- Rerun
--failed first - Faster than full rerun
- Watch long runs - Don't poll manually
- Download artifacts - For test reports, coverage, etc.
- Use JSON output - For scripting and parsing