-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit_site.sh
executable file
·51 lines (40 loc) · 1.36 KB
/
commit_site.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# ideas used from https://gist.github.com/motemen/8595451
# Based on https://github.com/eldarlabs/ghpages-deploy-script/blob/master/scripts/deploy-ghpages.sh
# Used with their MIT license https://github.com/eldarlabs/ghpages-deploy-script/blob/master/LICENSE
# abort the script if there is a non-zero error
set -e
# show where we are on the machine
pwd
remote=$(git config remote.origin.url)
siteSource="$1"
# what is this..?
if [ ! -d "$siteSource" ]
then
echo "Usage: $0 <site source dir>"
exit 1
fi
# make a directory to put the site branch
mkdir site
cd site
# now lets setup a new repo so we can update the site branch
git config --global user.email "action@github.com" > /dev/null 2>&1
git config --global user.name "GitHub Action" > /dev/null 2>&1
git init
git remote add --fetch origin "$remote"
# switch into the the site branch
if git rev-parse --verify origin/site > /dev/null 2>&1
then
git checkout site
# delete any old files as we are going to replace it
# Note: this explodes if there aren't any, so moving it here for now
git rm -rf .
else
git checkout --orphan site
fi
# copy over or recompile the new site
cp -a "../${siteSource}/." .
# stage any changes and new files
git add -A
# now commit, ignoring branch site doesn't seem to work, so trying skip
git commit --allow-empty -m "Deploy to GitHub branch site [ci skip]"