From fe4e449b2ffe716048904015720499ff871c60d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B6gl-Brunner=20Michel?= Date: Fri, 13 Nov 2026 13:02:11 +0100 Subject: [PATCH] pr-script-test: probe the token inside the guest, not on the host On the host the job token reads another repo's release fine (200), yet installs and updates in the guest hit the anonymous limit. Probe there, just before the update. Also drops the /tmp file named after $$. --- .github/workflows/scripts/pve-run-script.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/pve-run-script.sh b/.github/workflows/scripts/pve-run-script.sh index 1ac2cf25c..9ce5b2ad1 100644 --- a/.github/workflows/scripts/pve-run-script.sh +++ b/.github/workflows/scripts/pve-run-script.sh @@ -478,10 +478,6 @@ gh_quota() { jq -r '.rate | "\(.remaining) of \(.limit) left, resets in \(((.reset - now) / 60) | floor) min"' 2>/dev/null || echo "unknown" } echo "GitHub API quota: token $(gh_quota "${GH_API_TOKEN:-}") · no token $(gh_quota "")" -# Can the token read another owner's release, as every install does? -[[ -n "${GH_API_TOKEN:-}" ]] && echo "Token reads another repo's release: $(curl -s --max-time 10 -o /tmp/gh-probe.$$ -w '%{http_code}' \ - -H "Authorization: Bearer $GH_API_TOKEN" https://api.github.com/repos/cli/cli/releases/latest) $(jq -r '.message // .tag_name' /tmp/gh-probe.$$ 2>/dev/null)" -rm -f /tmp/gh-probe.$$ # --- Answers for the script's questions ------------------------------------------ # Nobody types into CI, so anything the install asks has to be answered up front. @@ -743,6 +739,10 @@ run_update() { : >"$raw" token=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n') echo "──────── $2 (live) ────────" + if [[ "$PLATFORM" == "incus" ]]; then guest_cmd_probe=(incus exec "$ctid" --); else guest_cmd_probe=(pct exec "$ctid" --); fi + # Diagnosis: does the token reach a GitHub call inside the guest? + [[ -n "${GH_API_TOKEN:-}" ]] && echo "Token inside the guest: $("${guest_cmd_probe[@]}" env GITHUB_TOKEN="$GH_API_TOKEN" sh -c \ + 'printf "%s chars, " "${#GITHUB_TOKEN}"; curl -s --max-time 10 -o /dev/null -w "%{http_code}" -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/cli/cli/releases/latest' 2>&1)" echo "::stop-commands::${token}" # timeout runs a program, not a shell function, so spell out the exec here. if [[ "$PLATFORM" == "incus" ]]; then guest_cmd=(incus exec "$ctid" --); else guest_cmd=(pct exec "$ctid" --); fi