workflows: surface GITHUB_TOKEN via env, use it in clone URL
Root cause of the earlier "Failed to authenticate" / "could not read
Username" failures: shell scripts in Gitea Actions don't automatically
inherit secrets — \${GITHUB_TOKEN} expanded to an empty string, so the
URL became "https://forgejo-runner:@..." (empty password) and Gitea's
auth layer rejected it.
Fix: explicit env: block on the Checkout step pulls the token in,
then the URL uses it via x-access-token (canonical token-as-password
username, accepted by Gitea, GitHub, Forgejo alike).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-10
@@ -28,12 +28,12 @@ jobs:
|
||||
runs-on: go
|
||||
steps:
|
||||
- name: Checkout
|
||||
env:
|
||||
# Gitea Actions doesn't auto-export GITHUB_TOKEN to the shell;
|
||||
# we have to read it from secrets and surface it explicitly.
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Public repo — clone without auth. Both Gitea and Forgejo
|
||||
# rejected hardcoded "forgejo-runner"/"x-access-token" basic-auth
|
||||
# formulas; for an unauthenticated read on public repos plain
|
||||
# https works on every server.
|
||||
git clone --no-checkout "https://git.okcu.io/${GITHUB_REPOSITORY}.git" /tmp/src
|
||||
git clone --no-checkout "https://x-access-token:${GITHUB_TOKEN}@git.okcu.io/${GITHUB_REPOSITORY}.git" /tmp/src
|
||||
git -C /tmp/src checkout "$GITHUB_SHA"
|
||||
cp -a /tmp/src/. .
|
||||
- name: Vet
|
||||
@@ -51,12 +51,12 @@ jobs:
|
||||
needs: test
|
||||
steps:
|
||||
- name: Checkout
|
||||
env:
|
||||
# Gitea Actions doesn't auto-export GITHUB_TOKEN to the shell;
|
||||
# we have to read it from secrets and surface it explicitly.
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Public repo — clone without auth. Both Gitea and Forgejo
|
||||
# rejected hardcoded "forgejo-runner"/"x-access-token" basic-auth
|
||||
# formulas; for an unauthenticated read on public repos plain
|
||||
# https works on every server.
|
||||
git clone --no-checkout "https://git.okcu.io/${GITHUB_REPOSITORY}.git" /tmp/src
|
||||
git clone --no-checkout "https://x-access-token:${GITHUB_TOKEN}@git.okcu.io/${GITHUB_REPOSITORY}.git" /tmp/src
|
||||
git -C /tmp/src checkout "$GITHUB_SHA"
|
||||
cp -a /tmp/src/. .
|
||||
- name: Cross-compile drover.exe (windows/amd64)
|
||||
|
||||
@@ -17,9 +17,10 @@ jobs:
|
||||
runs-on: go
|
||||
steps:
|
||||
- name: Checkout
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Public repo — clone without auth (see build.yml for rationale).
|
||||
git clone --no-checkout "https://git.okcu.io/${GITHUB_REPOSITORY}.git" /tmp/src
|
||||
git clone --no-checkout "https://x-access-token:${GITHUB_TOKEN}@git.okcu.io/${GITHUB_REPOSITORY}.git" /tmp/src
|
||||
git -C /tmp/src checkout "$GITHUB_SHA"
|
||||
cp -a /tmp/src/. .
|
||||
|
||||
|
||||
Reference in New Issue
Block a user