@@ -50,26 +50,51 @@ steps:
5050 run : |
5151 set -euo pipefail
5252 mkdir -p /tmp/gh-aw/token-audit
53+ PARTS_DIR=/tmp/gh-aw/token-audit/log-parts
54+ mkdir -p "$PARTS_DIR"
55+
56+ # Fetch logs per workflow to avoid repo-wide pagination truncation in
57+ # high-CI-volume repositories.
58+ FOUND_WORKFLOW=0
59+ for workflow in .github/workflows/*.md; do
60+ [ -f "$workflow" ] || continue
61+
62+ WORKFLOW_ID=$(sed -n 's/^tracker-id:[[:space:]]*//p' "$workflow" | head -n 1)
63+ [ -n "$WORKFLOW_ID" ] || continue
64+
65+ FOUND_WORKFLOW=1
66+ PART_FILE="$PARTS_DIR/$WORKFLOW_ID.json"
67+ PART_EXIT=0
68+ gh aw logs "$WORKFLOW_ID" \
69+ --start-date -1d \
70+ --json \
71+ -c 100 \
72+ > "$PART_FILE" || PART_EXIT=$?
73+
74+ if ! jq -e . "$PART_FILE" >/dev/null 2>&1; then
75+ echo "⚠️ $WORKFLOW_ID: invalid log JSON (exit code $PART_EXIT)"
76+ rm -f "$PART_FILE"
77+ continue
78+ fi
79+
80+ COUNT=$(jq '(.runs // []) | length' "$PART_FILE")
81+ if [ "$COUNT" -gt 0 ]; then
82+ echo "✅ $WORKFLOW_ID: downloaded $COUNT runs (exit code $PART_EXIT)"
83+ else
84+ echo "⚠️ $WORKFLOW_ID: no log data (exit code $PART_EXIT)"
85+ rm -f "$PART_FILE"
86+ fi
87+ done
5388
54- # Download last 24 hours of agentic workflow logs as JSON
55- # Allow partial results — gh aw logs streams incrementally, so even if
56- # it hits an API rate limit partway through, the JSON written so far is
57- # still valid and should be processed by the agent.
58- LOGS_EXIT=0
59- gh aw logs \
60- --start-date -1d \
61- --json \
62- -c 100 \
63- > /tmp/gh-aw/token-audit/workflow-logs.json || LOGS_EXIT=$?
64-
65- if [ -s /tmp/gh-aw/token-audit/workflow-logs.json ]; then
89+ if [ "$FOUND_WORKFLOW" -eq 1 ] && ls "$PARTS_DIR"/*.json >/dev/null 2>&1; then
90+ jq -s '{summary: {}, runs: (map(.runs // []) | add | unique_by(.run_id))}' \
91+ "$PARTS_DIR"/*.json > /tmp/gh-aw/token-audit/workflow-logs.json
6692 TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/workflow-logs.json)
6793 echo "✅ Downloaded $TOTAL agentic workflow runs (last 24 hours)"
68- if [ "$LOGS_EXIT" -ne 0 ]; then
69- echo "⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)"
70- fi
7194 else
72- echo "❌ No log data downloaded (exit code $LOGS_EXIT)"
95+ if [ "$FOUND_WORKFLOW" -eq 0 ]; then
96+ echo "⚠️ No agentic workflow sources found under .github/workflows"
97+ fi
7398 echo '{"runs":[],"summary":{}}' > /tmp/gh-aw/token-audit/workflow-logs.json
7499 fi
75100timeout-minutes : 25
0 commit comments