git » blacktide.git » commit 1332d99

Preserve the Forgejo server path during CI checkout

author Alan Dipert
2026-11-06 20:27:47 UTC
committer Alan Dipert
2026-11-06 20:27:47 UTC
parent f9e37e997d61d2365b85c90d9ab45da00d2b7e12

Preserve the Forgejo server path during CI checkout

.forgejo/workflows/check.yml +12 -3

diff --git a/.forgejo/workflows/check.yml b/.forgejo/workflows/check.yml
index 52fe86f..3a45a22 100644
--- a/.forgejo/workflows/check.yml
+++ b/.forgejo/workflows/check.yml
@@ -14,9 +14,18 @@ jobs:
       matrix:
         java: ['17', '21', '25', '27']
     steps:
-      - uses: https://github.com/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
-        with:
-          persist-credentials: false
+      # actions/checkout discards the server URL's /forgejo path.
+      - name: Checkout
+        env:
+          CHECKOUT_TOKEN: ${{ github.token }}
+        run: |
+          git init -q
+          git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git"
+          auth=$(printf 'x-access-token:%s' "$CHECKOUT_TOKEN" | base64 -w0)
+          GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader \
+            GIT_CONFIG_VALUE_0="AUTHORIZATION: basic $auth" \
+            git fetch --no-tags --depth=1 origin "$GITHUB_SHA"
+          git checkout --detach FETCH_HEAD
       - uses: https://github.com/actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
         with:
           distribution: temurin