Skip to content

Commit c28eefe

Browse files
committed
harden gh-pages publish step for first-run and worktree safety
1 parent 6618148 commit c28eefe

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

.github/workflows/deploy-docs-pages.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ jobs:
4444
set -euo pipefail
4545
4646
PUBLISH_DIR="${RUNNER_TEMP}/gh-pages"
47+
48+
# Clean up stale worktree path from prior attempts.
49+
git worktree remove --force "$PUBLISH_DIR" 2>/dev/null || true
50+
rm -rf "$PUBLISH_DIR"
51+
4752
git fetch origin gh-pages || true
4853
4954
if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
@@ -52,7 +57,8 @@ jobs:
5257
git worktree add -B gh-pages "$PUBLISH_DIR"
5358
fi
5459
55-
rsync -av --delete .site/ "$PUBLISH_DIR"/
60+
# Keep worktree git metadata intact.
61+
rsync -av --delete --exclude='.git' .site/ "$PUBLISH_DIR"/
5662
touch "$PUBLISH_DIR/.nojekyll"
5763
5864
cd "$PUBLISH_DIR"

0 commit comments

Comments
 (0)