forked from mozilla/pdf.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy-dist.sh
executable file
·56 lines (43 loc) · 1.43 KB
/
deploy-dist.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
52
53
54
55
56
#!/bin/sh
# ideas used from https://gist.github.com/motemen/8595451
# abort the script if there is a non-zero error
set -e
# show where we are on the machine
pwd
LAST_COMMIT=$(git rev-parse --short HEAD)
remote=$(git config remote.origin.url)
DIRECTORY=gh-dist-branch
# make a directory to put the gp-pages branch
if [ -d "$DIRECTORY" ]; then
rm -rf $DIRECTORY
fi
mkdir $DIRECTORY
cd gh-dist-branch
# now lets setup a new repo so we can update the gh-pages branch
git init
git remote add origin "$remote"
# Fetch only the specific branch with a shallow clone
git fetch --depth 1 origin dist-v3
# switch into the the gh-pages branch
if git rev-parse --verify origin/dist-v3 > /dev/null 2>&1
then
git checkout dist-v3
# delete any old site 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 dist-v3
fi
# copy over or recompile the new site
cp -R ../build/dist/* ./
# stage any changes and new files
git add -A
# now commit, ignoring branch gh-pages doesn't seem to work, so trying skip
git commit --allow-empty -m "Auto-deploy dist-v3, commit $LAST_COMMIT"
# and push, but send any output to /dev/null to hide anything sensitive
git push --force --quiet origin dist-v3 > /dev/null 2>&1
# go back to where we started and remove the gh-pages git repo we made and used
# for deployment
cd ..
rm -rf gh-dist-branch
echo "Finished Deployment!"