File size: 2,847 Bytes
1f2d50a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# GitHub Actions Debugging - Quick Reference
## π Most Common Commands
```bash
# Quick failure check
just gh-actions-check
# Generate full debugging report
just gh-actions-report
# Debug JSON/Matrix issues
just gh-actions-debug-json
# Re-run failed workflow
just gh-actions-rerun
```
## π Debugging Commands
### Basic Analysis
```bash
just gh-actions-debug # Basic analysis
just gh-actions-debug-full # Comprehensive (verbose, 50 runs)
just gh-actions-debug-run 12345 # Debug specific run ID
```
### Focused Analysis
```bash
just gh-actions-debug-json # JSON/Matrix issues only
just gh-actions-debug-workflows # Workflow files only
```
### Quick Checks
```bash
just gh-actions-check # List 5 recent failures
just gh-actions-logs # View latest failed logs
just gh-actions-job-logs ID JOB # Specific job logs
just gh-actions-watch # Real-time monitoring
```
## π Workflow Management
```bash
just gh-actions-rerun # Re-run latest failed
just gh-actions-rerun-id 12345 # Re-run specific ID
just gh-actions-cancel # Cancel all running
```
## β
Validation & Testing
```bash
just gh-actions-list-workflows # List workflow files
just gh-actions-validate ci.yml # Validate YAML syntax
just gh-actions-test-matrix # Test matrix generation
```
## π Reports & Maintenance
```bash
just gh-actions-report # Generate & open report
just gh-actions-clean-reports # Clean reports >7 days old
```
## π‘ Common Fixes
### Fix Matrix JSON Output
```yaml
# Bad:
echo "matrix=$JSON" >> $GITHUB_OUTPUT
# Good:
printf 'matrix=%s\n' "$JSON" >> "$GITHUB_OUTPUT"
```
### Handle Empty Arrays
```yaml
if [ -z "$MATRIX_JSON" ] || [ "$MATRIX_JSON" = '{"include":[]}' ]; then
echo 'matrix={"include":[{"name":"default","path":"src"}]}' >> $GITHUB_OUTPUT
else
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
fi
```
### Validate JSON Before Output
```yaml
echo "$MATRIX_JSON" | jq . > /dev/null || {
echo "Invalid JSON generated"
echo 'matrix={"include":[]}' >> $GITHUB_OUTPUT
exit 0
}
```
## π οΈ Direct Script Usage
```bash
# With options
python scripts/gh_actions_debug.py --verbose --limit 50 --focus json
# Export artifacts
python scripts/gh_actions_debug.py --export-artifacts
# Custom output directory
python scripts/gh_actions_debug.py -o /tmp/gh-debug
```
## π Output Locations
- Reports: `debug-reports/github_actions_debug_*.md`
- Latest report: `ls -t debug-reports/*.md | head -1`
## π Prerequisites
- GitHub CLI: `gh auth status`
- Python 3.8+: `python --version`
- Optional: `jq` for JSON processing
- Optional: `yq` for YAML validation
## β Help
```bash
just help-gh-actions # Show all commands
just gh-actions-debug --help # Script options
``` |