Add deployment automation and update documentation
This commit is contained in:
59
deploy.sh
Executable file
59
deploy.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy.sh - Build and deploy to orphan deploy branch
|
||||
# Usage: ./deploy.sh [commit-message]
|
||||
|
||||
set -e
|
||||
|
||||
COMMIT_MSG="${1:-Deploy: $(date +'%Y-%m-%d %H:%M:%S')}"
|
||||
|
||||
echo "📦 Building site on main branch..."
|
||||
bun run build
|
||||
|
||||
if [ ! -d "build" ]; then
|
||||
echo "❌ Build failed - build directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Build successful"
|
||||
echo ""
|
||||
echo "🔄 Switching to deploy branch..."
|
||||
git checkout deploy
|
||||
|
||||
echo "🧹 Cleaning deploy branch (keeping .git and .gitignore)..."
|
||||
# Remove all tracked files except .gitignore
|
||||
git ls-files | grep -v "^\.gitignore$" | xargs -r git rm -f
|
||||
# Remove any untracked files/directories except build/, node_modules/, and .svelte-kit/
|
||||
find . -mindepth 1 -maxdepth 1 ! -name 'build' ! -name 'node_modules' ! -name '.svelte-kit' ! -name '.git' ! -name '.gitignore' -exec rm -rf {} +
|
||||
|
||||
echo "📋 Copying build output to root..."
|
||||
if [ -d "build" ]; then
|
||||
mv build/* .
|
||||
rm -rf build/
|
||||
echo "✅ Build files copied to deploy branch root"
|
||||
else
|
||||
echo "⚠️ No build directory found (this is expected on deploy branch)"
|
||||
fi
|
||||
|
||||
echo "📝 Staging changes..."
|
||||
git add -A
|
||||
|
||||
# Check if there are any changes to commit
|
||||
if git diff --staged --quiet; then
|
||||
echo "ℹ️ No changes to deploy"
|
||||
git checkout main
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "💾 Committing build artifacts..."
|
||||
git commit -m "$COMMIT_MSG"
|
||||
|
||||
echo "🚀 Pushing to origin/deploy..."
|
||||
git push origin deploy
|
||||
|
||||
echo "✅ Switching back to main..."
|
||||
git checkout main
|
||||
|
||||
echo ""
|
||||
echo "✨ Deployment complete!"
|
||||
echo " Deploy branch commit: $(git rev-parse --short deploy)"
|
||||
echo " Main branch commit: $(git rev-parse --short main)"
|
||||
Reference in New Issue
Block a user