From 0d6ccba1b4edb29b8096e56afb66279fc58cee34 Mon Sep 17 00:00:00 2001 From: bdadevops Date: Mon, 8 Jun 2026 09:08:31 +0000 Subject: [PATCH] fix(go-ci): use job-scoped GIT_CONFIG env vars instead of global extraHeader http.extraHeader doesn't satisfy git's credential check (causes "could not read Username" in go mod download) and persists in ~/.gitconfig on self-hosted runners, where it collides with actions/checkout@v4's own extraHeader and produces "Duplicate header: Authorization" / exit 128. Replace it with GIT_CONFIG_COUNT/KEY/VALUE env vars exported via GITHUB_ENV, using url.insteadOf semantics (the mechanism Go's own FAQ recommends for private modules). This is job-scoped, never touches ~/.gitconfig, and uses a different config key than checkout so it cannot collide. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/go-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml index b0d2add..7c1cb1e 100644 --- a/.github/workflows/go-ci.yml +++ b/.github/workflows/go-ci.yml @@ -63,7 +63,9 @@ jobs: GH_PAT: ${{ secrets.GH_PAT }} run: | if [ -n "$GH_PAT" ]; then - git config --global http."https://github.com/".extraHeader "Authorization: token ${GH_PAT}" + echo "GIT_CONFIG_COUNT=1" >> "$GITHUB_ENV" + echo "GIT_CONFIG_KEY_0=url.https://${GH_PAT}@github.com/.insteadOf" >> "$GITHUB_ENV" + echo "GIT_CONFIG_VALUE_0=https://github.com/" >> "$GITHUB_ENV" fi - uses: actions/setup-go@v5 @@ -108,7 +110,9 @@ jobs: GH_PAT: ${{ secrets.GH_PAT }} run: | if [ -n "$GH_PAT" ]; then - git config --global http."https://github.com/".extraHeader "Authorization: token ${GH_PAT}" + echo "GIT_CONFIG_COUNT=1" >> "$GITHUB_ENV" + echo "GIT_CONFIG_KEY_0=url.https://${GH_PAT}@github.com/.insteadOf" >> "$GITHUB_ENV" + echo "GIT_CONFIG_VALUE_0=https://github.com/" >> "$GITHUB_ENV" fi - uses: actions/setup-go@v5 @@ -147,7 +151,9 @@ jobs: GH_PAT: ${{ secrets.GH_PAT }} run: | if [ -n "$GH_PAT" ]; then - git config --global http."https://github.com/".extraHeader "Authorization: token ${GH_PAT}" + echo "GIT_CONFIG_COUNT=1" >> "$GITHUB_ENV" + echo "GIT_CONFIG_KEY_0=url.https://${GH_PAT}@github.com/.insteadOf" >> "$GITHUB_ENV" + echo "GIT_CONFIG_VALUE_0=https://github.com/" >> "$GITHUB_ENV" fi - uses: actions/setup-go@v5