-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-deploy.sh
More file actions
executable file
·92 lines (70 loc) · 2.07 KB
/
simple-deploy.sh
File metadata and controls
executable file
·92 lines (70 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# simple-deploy.sh - Simple deployment script that fixes the header link
set -e # Exit on error
REPO_URL=$1
# Check for repository URL
if [ -z "$REPO_URL" ]; then
REPO_URL=$(git remote get-url origin 2>/dev/null || echo "")
# If still empty, prompt the user
if [ -z "$REPO_URL" ]; then
echo "Repository URL not found. Please provide it:"
read -r REPO_URL
if [ -z "$REPO_URL" ]; then
echo "Error: No repository URL provided. Cannot deploy."
exit 1
fi
fi
fi
echo "===== RUBY LEARNING DEPLOYMENT ====="
echo "Using repository URL: $REPO_URL"
# Make scripts executable
chmod +x bin/* 2>/dev/null || echo "Warning: Could not make bin scripts executable"
chmod +x fix-header-link.rb
# Build the site
echo "1. Building the site..."
if [ -x "bin/typophic" ]; then
bin/typophic build --deploy
else
echo "Error: No build script found."
exit 1
fi
# Fix the header link
echo "2. Fixing header link to point to /posts/ instead of /pages/..."
ruby fix-header-link.rb
# Make sure .nojekyll exists
echo "3. Adding .nojekyll file..."
touch public/.nojekyll
# Deploy to GitHub Pages
echo "4. Deploying to GitHub Pages..."
TMP_DIR=$(mktemp -d)
echo " - Created temporary directory: $TMP_DIR"
# Copy the public directory contents
cp -r public/* "$TMP_DIR/"
cp public/.nojekyll "$TMP_DIR/"
echo " - Copied site files"
# Navigate to the temporary directory
cd "$TMP_DIR" || exit
# Initialize git
git init
git checkout -b gh-pages
echo " - Initialized git repository"
# Add all files
git add .
# Commit
git commit -m "Deploy to GitHub Pages - $(date)"
echo " - Committed changes"
# Add remote
git remote add origin "$REPO_URL"
# Push (with force)
git push -f origin gh-pages
echo " - Pushed to gh-pages branch"
# Clean up
cd - || exit
rm -rf "$TMP_DIR"
echo " - Cleaned up temporary directory"
# Push source changes to main branch
echo "5. Pushing source changes to main branch..."
git push origin main
echo "===== DEPLOYMENT COMPLETE ====="
echo "Your site has been deployed to GitHub Pages!"
echo "It may take a few minutes for the changes to appear."