Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdeploy.sh
More file actions
Latest commit
executable file
·91 lines (73 loc) · 2.11 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·91 lines (73 loc) · 2.11 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
#!/bin/bash
# Deploy script for QPython documentation
# Builds the site and deploys to gh-pages branch
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"&& pwd)"
cd"$SCRIPT_DIR"
# Run build first
echo"Building site..."
./build.sh
# Check if git repository
if [ !-d .git ];then
echo"Error: Not a git repository"
exit 1
fi
# Get current branch
CURRENT_BRANCH=$(git branch --show-current)
echo"Current branch: $CURRENT_BRANCH"
# Check if there are uncommitted changes
if! git diff-index --quiet HEAD --;then
echo"Warning: You have uncommitted changes. Please commit them first."
echo"Uncommitted files:"
git status --short
read -p "Do you want to continue anyway? (y/N) " -n 1 -r
echo
if [[ !$REPLY=~ ^[Yy]$ ]];then
echo"Aborted."
exit 1
fi
fi
# Deploy to gh-pages
echo""
echo"Deploying to gh-pages branch..."
# Create a temporary directory for the site
TEMP_DIR=$(mktemp -d)
cp -r site/*"$TEMP_DIR/"
# Switch to gh-pages branch (create if doesn't exist)
if git show-ref --verify --quiet refs/heads/gh-pages;then
git checkout gh-pages
else
git checkout --orphan gh-pages
git rm -rf . -- ':!deploy.sh'
fi
# Remove old files (except .git and deploy.sh)
find . -maxdepth 1 ! -name '.git'! -name 'deploy.sh'! -name '.'! -name '..' -exec rm -rf {} \;
# Copy new site content
cp -r "$TEMP_DIR"/*.
# Add all files
git add -A
# Commit
COMMIT_MSG="Deploy site - $(date '+%Y-%m-%d %H:%M:%S')"
if git diff --cached --quiet;then
echo"No changes to commit"
else
git commit -m "$COMMIT_MSG"
echo"Committed: $COMMIT_MSG"
fi
# Push to remote with force (gh-pages is safe to force push)
read -p "Push to origin/gh-pages? (y/N) " -n 1 -r
echo
if [[ $REPLY=~ ^[Yy]$ ]];then
git push origin gh-pages --force
echo""
echo"Deployed successfully!"
echo"Site will be available at: https://qpython-android.github.io/qpython.org/"
else
echo"Push aborted. You can push manually with: git push origin gh-pages --force"
fi
# Cleanup
rm -rf "$TEMP_DIR"
# Switch back to original branch
git checkout "$CURRENT_BRANCH"
echo""
echo"Done!"