fix: CI checkout with token auth for private repo
Some checks failed
Build Archipelago ISO / build-iso (push) Failing after 0s
Some checks failed
Build Archipelago ISO / build-iso (push) Failing after 0s
Manual git clone needs GITHUB_TOKEN injected for private repos. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,15 +13,17 @@ jobs:
|
||||
- name: Checkout
|
||||
run: |
|
||||
WORKSPACE="${GITHUB_WORKSPACE:-$(pwd)}"
|
||||
cd "$WORKSPACE"
|
||||
if [ -d .git ]; then
|
||||
git fetch origin "${GITHUB_REF_NAME:-main}" --depth 1
|
||||
git checkout FETCH_HEAD
|
||||
else
|
||||
git clone --depth 1 --branch "${GITHUB_REF_NAME:-main}" \
|
||||
"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" "$WORKSPACE"
|
||||
CLONE_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||
# Inject token for private repo auth
|
||||
if [ -n "$GITHUB_TOKEN" ]; then
|
||||
CLONE_URL=$(echo "$CLONE_URL" | sed "s|https://|https://token:${GITHUB_TOKEN}@|")
|
||||
fi
|
||||
rm -rf "$WORKSPACE"
|
||||
git clone --depth 1 --branch "${GITHUB_REF_NAME:-main}" "$CLONE_URL" "$WORKSPACE"
|
||||
cd "$WORKSPACE"
|
||||
echo "Checked out $(git rev-parse --short HEAD) on ${GITHUB_REF_NAME:-main}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build backend
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user