Skip to content

Commit 8cc83f0

Browse files
TalZaccaiCopilot
andauthored
Fix Dependabot workflow: add error logging (#2140)
The \ ix-dependabot-alerts\ workflow ran successfully but found zero packages because the script's stderr was silently redirected to a temp file and never printed. ### Change When the script produces no valid JSON output, the stderr log is now printed to the job log for debugging. ### How to verify Merge this PR, then re-run the workflow. The stderr output will reveal the actual error (likely a 403 from the Dependabot alerts API due to \GITHUB_TOKEN\ limitations). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2a77373 commit 8cc83f0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/fix-dependabot-alerts.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
# Automatically remediate Dependabot security alerts by running the
55
# fix-dependabot-alerts script, verifying the build for each fix,
66
# and opening a pull request with the passing changes.
7+
#
8+
# REQUIRED: A repository secret named DEPENDABOT_PAT containing a
9+
# Personal Access Token (classic) with the `security_events` scope,
10+
# or a fine-grained token with "Dependabot alerts" read permission.
11+
# The default GITHUB_TOKEN cannot access the Dependabot alerts API.
712

813
name: fix-dependabot-alerts
914

@@ -69,14 +74,19 @@ jobs:
6974
id: fix
7075
working-directory: ts
7176
env:
72-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
# NOTE: GITHUB_TOKEN cannot access Dependabot alerts API (403).
78+
# A PAT with security_events scope must be stored as DEPENDABOT_PAT.
79+
GH_TOKEN: ${{ secrets.DEPENDABOT_PAT || secrets.GITHUB_TOKEN }}
7380
run: |
7481
# ── Step 1: Discover fixable packages ───────────────────────
7582
echo "::group::Analysing alerts"
7683
node tools/scripts/fix-dependabot-alerts.mjs --dry-run --json > /tmp/dep-analysis.json 2>/tmp/dep-analysis.log || true
7784
7885
if ! jq -e '.summary' /tmp/dep-analysis.json > /dev/null 2>&1; then
79-
echo "Script produced no JSON output"
86+
echo "::error::Script produced no valid JSON output"
87+
echo "--- stderr log ---"
88+
cat /tmp/dep-analysis.log || true
89+
echo "--- end stderr log ---"
8090
echo "resolved=0" >> "$GITHUB_OUTPUT"
8191
echo "blocked=0" >> "$GITHUB_OUTPUT"
8292
echo "failed=0" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)