fix: CI checkout cd to home before cleanup to avoid cwd error

The runner cwd is the workspace itself, so deleting it removes the
shell's cwd. cd to home first, then clean workspace before clone.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian 2026-03-26 14:24:24 +00:00
parent 30cc2378d2
commit 525779f4aa

View File

@ -12,13 +12,13 @@ jobs:
steps:
- name: Checkout
run: |
WORKSPACE="${GITHUB_WORKSPACE:-$(pwd)}"
cd /home/archipelago
WORKSPACE="${GITHUB_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"
[ -d "$WORKSPACE" ] && find "$WORKSPACE" -mindepth 1 -delete
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}"