Skip to content

Commit ba6bdb1

Browse files
committed
Deploy site 2025-09-26 13:41:37
1 parent b9f15ce commit ba6bdb1

1 file changed

Lines changed: 22 additions & 28 deletions

File tree

.deploy/scripts/deploy-gpt.sh

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
11
#!/usr/bin/env bash
2-
# Deploy Jekyll site to gh-pages branch using git worktree
2+
# Lightweight Jekyll deploy script
33
set -euo pipefail
44

5-
BRANCH="gh-pages"
6-
DEPLOY_DIR=".deploy"
5+
# Config
6+
REMOTE=origin
7+
BRANCH=gh-pages
8+
BUILD_DIR=_site
79

8-
echo "==> Cleaning up any stale worktrees..."
9-
git worktree prune
10-
rm -rf "$DEPLOY_DIR"
11-
12-
# Ensure gh-pages branch exists
13-
if ! git show-ref --quiet refs/heads/$BRANCH; then
14-
echo "==> Creating $BRANCH branch..."
15-
git branch $BRANCH
16-
fi
10+
echo "Building Jekyll site..."
11+
bundle exec jekyll build
1712

18-
echo "==> Adding worktree for $BRANCH..."
19-
git worktree add -B $BRANCH "$DEPLOY_DIR" origin/$BRANCH || git worktree add -B $BRANCH "$DEPLOY_DIR"
13+
echo "Preparing temporary git repo in $BUILD_DIR..."
14+
cd "$BUILD_DIR"
2015

21-
echo "==> Building Jekyll site..."
22-
bundle exec jekyll build
16+
# Init repo if needed
17+
if [ ! -d ".git" ]; then
18+
git init
19+
git remote add $REMOTE "$(git -C .. config --get remote.$REMOTE.url)"
20+
fi
2321

24-
echo "==> Syncing built site into $DEPLOY_DIR..."
25-
rsync -av --delete _site/ "$DEPLOY_DIR/"
22+
# Reset state each deploy
23+
git checkout -B $BRANCH
2624

27-
echo "==> Committing and pushing..."
28-
cd "$DEPLOY_DIR"
29-
git add --all
30-
git commit -m "Deploy site $(date)" || echo "Nothing to commit"
31-
git push origin $BRANCH
32-
cd -
25+
echo "Committing build..."
26+
git add -A
27+
git commit -m "Deploy site $(date)" || echo "No changes to commit."
3328

34-
echo "==> Cleaning up temporary worktree..."
35-
git worktree remove "$DEPLOY_DIR" --force
36-
rm -rf "$DEPLOY_DIR"
29+
echo "Pushing to $REMOTE/$BRANCH..."
30+
git push -f $REMOTE HEAD:$BRANCH
3731

38-
echo "==> Deployment complete!"
32+
echo "Deployment complete!"

0 commit comments

Comments
 (0)