From 8318f8f198926d467b0e36492a92e3ffd9b737e1 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 8 Nov 2026 20:55:28 -0800 Subject: [PATCH] ci: fail clearly when DOCS_BOT_TOKEN is missing or expired The docs workflow has failed on every push to main since Aug 31 with git's "could not read Username for 'https://github.com'" from checkout, because DOCS_BOT_TOKEN no longer authenticates. Check the token before checkout in both workflows that use it and say what's wrong and how to fix it. Signed-off-by: Tim Smith --- .github/workflows/docs.yml | 21 ++++++++++++++++++++ .github/workflows/release-readme-version.yml | 21 ++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b9b37ede..fd6cd3e5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,6 +12,27 @@ jobs: name: Regenerate docs/commands runs-on: ubuntu-latest steps: + # Fail fast with a clear message when the token has expired or been + # revoked. Otherwise checkout fails with git's unhelpful + # "could not read Username for 'https://github.com'". + - name: Check DOCS_BOT_TOKEN + env: + TOKEN: ${{ secrets.DOCS_BOT_TOKEN }} + run: | + fix="Create a new PAT (contents: write on ${GITHUB_REPOSITORY}) for an account on main's branch-protection bypass list and save it as the DOCS_BOT_TOKEN repository secret." + if [[ -z "$TOKEN" ]]; then + echo "::error::DOCS_BOT_TOKEN isn't set. ${fix}" + exit 1 + fi + if ! push=$(GH_TOKEN="$TOKEN" gh api "repos/${GITHUB_REPOSITORY}" --jq .permissions.push 2>&1); then + echo "::error::GitHub rejected DOCS_BOT_TOKEN (${push}). It has probably expired or been revoked. ${fix}" + exit 1 + fi + if [[ "$push" != "true" ]]; then + echo "::error::DOCS_BOT_TOKEN works but can't push to ${GITHUB_REPOSITORY}. ${fix}" + exit 1 + fi + - name: Check out code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/.github/workflows/release-readme-version.yml b/.github/workflows/release-readme-version.yml index fb3effa3..c0ebdd6d 100644 --- a/.github/workflows/release-readme-version.yml +++ b/.github/workflows/release-readme-version.yml @@ -15,6 +15,27 @@ jobs: if: ${{ !github.event.release.prerelease }} runs-on: ubuntu-latest steps: + # Fail fast with a clear message when the token has expired or been + # revoked. Otherwise checkout fails with git's unhelpful + # "could not read Username for 'https://github.com'". + - name: Check DOCS_BOT_TOKEN + env: + TOKEN: ${{ secrets.DOCS_BOT_TOKEN }} + run: | + fix="Create a new PAT (contents: write on ${GITHUB_REPOSITORY}) for an account on main's branch-protection bypass list and save it as the DOCS_BOT_TOKEN repository secret." + if [[ -z "$TOKEN" ]]; then + echo "::error::DOCS_BOT_TOKEN isn't set. ${fix}" + exit 1 + fi + if ! push=$(GH_TOKEN="$TOKEN" gh api "repos/${GITHUB_REPOSITORY}" --jq .permissions.push 2>&1); then + echo "::error::GitHub rejected DOCS_BOT_TOKEN (${push}). It has probably expired or been revoked. ${fix}" + exit 1 + fi + if [[ "$push" != "true" ]]; then + echo "::error::DOCS_BOT_TOKEN works but can't push to ${GITHUB_REPOSITORY}. ${fix}" + exit 1 + fi + - name: Check out main uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: