-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
executable file
·37 lines (36 loc) · 997 Bytes
/
deploy.sh
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
#!/bin/bash
source ~/.bashrc
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
rm -rf biglab-temp
git clone [email protected]:cmubig/cmubig.github.io.git biglab-temp
cd biglab-temp
last_commit=$(git log -1 --format="%at" | xargs -I{} date -d @{} +%s)
git clone [email protected]:cmubig/cmubig.github.io.git _site
cd _site
last_push=$(git log -1 --format="%at" | xargs -I{} date -d @{} +%s)
if [ $last_commit -ge $last_push ]; then
cd ..
rm -rf _site
sudo docker run --rm --volume="$PWD:/srv/jekyll" jekyll/jekyll:4.0 jekyll build
if [ -d "_site" ]; then
cd _site
git init
git remote add origin [email protected]:cmubig/cmubig.github.io.git
touch .nojekyll
touch CNAME
echo "cmubig.github.io" >> CNAME
git add -A
git commit -m "Auto deploy"
git push -f origin main
cd ../../
rm -rf biglab-temp
echo "Pushed changes!"
else
echo "Failed to push!"
fi
else
cd ../../
rm -rf biglab-temp
echo "Up to date!"
fi