|
| 1 | +set shell := ["bash", "-uc"] |
| 2 | + |
| 3 | +# List available recipes |
| 4 | +list: |
| 5 | + just --list |
| 6 | + |
| 7 | +# Get logs from the latest GitHub Actions workflow run |
| 8 | +get-latest-logs output="latest-run.log": |
| 9 | + #!/usr/bin/env bash |
| 10 | + set -euxo pipefail |
| 11 | + echo "Fetching latest workflow run..." |
| 12 | + |
| 13 | + # Get the latest run ID |
| 14 | + RUN_ID=$(gh run list --limit 1 --json databaseId --jq '.[0].databaseId') |
| 15 | + |
| 16 | + if [ -z "$RUN_ID" ]; then |
| 17 | + echo "Error: No workflow runs found" |
| 18 | + exit 1 |
| 19 | + fi |
| 20 | + |
| 21 | + echo "Latest run ID: $RUN_ID" |
| 22 | + |
| 23 | + # Get the logs and save to file |
| 24 | + gh run view "$RUN_ID" --log > "{{output}}" |
| 25 | + |
| 26 | + echo "Logs saved to: {{output}}" |
| 27 | + echo "Run 'just analyze-logs' to get AI analysis of the failure" |
| 28 | + |
| 29 | +# Get logs from a specific workflow run by ID |
| 30 | +get-logs run_id output="run.log": |
| 31 | + #!/usr/bin/env bash |
| 32 | + set -euxo pipefail |
| 33 | + echo "Fetching logs for run ID: {{run_id}}" |
| 34 | + gh run view {{run_id}} --log > "{{output}}" |
| 35 | + echo "Logs saved to: {{output}}" |
| 36 | + |
| 37 | +# List recent workflow runs |
| 38 | +list-runs limit="10": |
| 39 | + #!/usr/bin/env bash |
| 40 | + set -euxo pipefail |
| 41 | + echo "Recent workflow runs:" |
| 42 | + gh run list --limit {{limit}} --json databaseId,status,conclusion,name,createdAt,displayTitle |
| 43 | + |
| 44 | +# Get detailed status of the latest workflow run |
| 45 | +status-latest: |
| 46 | + #!/usr/bin/env bash |
| 47 | + set -euxo pipefail |
| 48 | + echo "Latest workflow run status:" |
| 49 | + gh run list --limit 1 --json databaseId,status,conclusion,name,createdAt,displayTitle,workflowName,event,headBranch |
| 50 | + echo "" |
| 51 | + echo "Jobs in latest run:" |
| 52 | + RUN_ID=$(gh run list --limit 1 --json databaseId --jq '.[0].databaseId') |
| 53 | + gh run view "$RUN_ID" |
| 54 | + |
| 55 | +# Get logs from the latest failed workflow run |
| 56 | +get-failed-logs output="failed-run.log": |
| 57 | + #!/usr/bin/env bash |
| 58 | + set -euxo pipefail |
| 59 | + echo "Fetching latest failed workflow run..." |
| 60 | + |
| 61 | + # Get the latest failed run ID |
| 62 | + RUN_ID=$(gh run list --limit 50 --json databaseId,conclusion --jq '.[] | select(.conclusion=="failure") | .databaseId' | head -n 1) |
| 63 | + |
| 64 | + if [ -z "$RUN_ID" ]; then |
| 65 | + echo "Error: No failed workflow runs found in the last 50 runs" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + |
| 69 | + echo "Latest failed run ID: $RUN_ID" |
| 70 | + |
| 71 | + # Get the logs and save to file |
| 72 | + gh run view "$RUN_ID" --log > "{{output}}" |
| 73 | + |
| 74 | + echo "Logs saved to: {{output}}" |
| 75 | + echo "Run 'just analyze-logs {{output}}' to get AI analysis of the failure" |
| 76 | + |
| 77 | +# Watch workflow runs in real-time |
| 78 | +watch: |
| 79 | + gh run watch |
| 80 | + |
| 81 | +# Re-run the latest failed workflow |
| 82 | +rerun-failed: |
| 83 | + #!/usr/bin/env bash |
| 84 | + set -euxo pipefail |
| 85 | + RUN_ID=$(gh run list --limit 50 --json databaseId,conclusion --jq '.[] | select(.conclusion=="failure") | .databaseId' | head -n 1) |
| 86 | + if [ -z "$RUN_ID" ]; then |
| 87 | + echo "Error: No failed workflow runs found" |
| 88 | + exit 1 |
| 89 | + fi |
| 90 | + echo "Re-running failed workflow: $RUN_ID" |
| 91 | + gh run rerun "$RUN_ID" |
| 92 | + |
| 93 | +# Cancel the latest running workflow |
| 94 | +cancel-latest: |
| 95 | + #!/usr/bin/env bash |
| 96 | + set -euxo pipefail |
| 97 | + RUN_ID=$(gh run list --limit 1 --json databaseId,status --jq '.[] | select(.status=="in_progress") | .databaseId' | head -n 1) |
| 98 | + if [ -z "$RUN_ID" ]; then |
| 99 | + echo "No running workflows found" |
| 100 | + exit 1 |
| 101 | + fi |
| 102 | + echo "Cancelling workflow run: $RUN_ID" |
| 103 | + gh run cancel "$RUN_ID" |
0 commit comments