Do not delete the workspace from inside it

The checkout step ran rm -rf on $GITHUB_WORKSPACE while the shell's working
directory was that same path. git then failed with 'Unable to read current
working directory', and every later step died with 'fork/exec /usr/bin/bash: no
such file or directory' for the same reason.

Both the checkout and the cleanup step now cd to / first.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-04 22:36:47 +02:00
parent e964933af1
commit 8b2e1275af

View File

@@ -44,6 +44,10 @@ jobs:
# and has no Node.js runtime for JavaScript actions. # and has no Node.js runtime for JavaScript actions.
run: | run: |
set -eux set -eux
# Step out of the workspace before removing it: the shell starts *in*
# $GITHUB_WORKSPACE, and deleting the current working directory makes
# every later command fail with "Unable to read current working directory".
cd /
rm -rf "$GITHUB_WORKSPACE" rm -rf "$GITHUB_WORKSPACE"
git clone --depth 1 --branch "$GITHUB_REF_NAME" \ git clone --depth 1 --branch "$GITHUB_REF_NAME" \
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" "$GITHUB_WORKSPACE" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" "$GITHUB_WORKSPACE"
@@ -120,5 +124,7 @@ jobs:
if: always() if: always()
run: | run: |
# A 1.5 GB artifact per run would fill the builder otherwise. # A 1.5 GB artifact per run would fill the builder otherwise.
# Runs even when an earlier step left the workspace missing, so cd out first.
cd /
rm -rf "$GITHUB_WORKSPACE/dist" "$GITHUB_WORKSPACE/build" || true rm -rf "$GITHUB_WORKSPACE/dist" "$GITHUB_WORKSPACE/build" || true
df -h / | tail -1 df -h / | tail -1