Skip to content

Commit 909044a

Browse files
committed
deploy script
1 parent 3d6fe94 commit 909044a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

deploy.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -e #abort if any command fails
3+
4+
deploy_directory=dist
5+
deploy_branch=gh-pages
6+
7+
commit_title=`git log -n 1 --format="%s" HEAD`
8+
commit_hash=`git log -n 1 --format="%H" HEAD`
9+
10+
previous_branch=`git rev-parse --abbrev-ref HEAD`
11+
if [[ $previous_branch = "HEAD" ]]; then
12+
previous_branch=$commit_hash
13+
fi
14+
15+
if ! ( git diff --exit-code --quiet \
16+
&& git diff --exit-code --quiet --cached ); then
17+
echo Aborting due to uncommitted changes
18+
exit 1
19+
fi
20+
21+
git --work-tree $deploy_directory checkout $deploy_branch --force
22+
git --work-tree $deploy_directory add --all
23+
24+
if git diff --exit-code --quiet HEAD; then
25+
git --work-tree $deploy_directory commit -m \
26+
"publish: $commit_title"$'\n\n'"generated from commit $commit_hash"
27+
git push -n $deploy_branch
28+
else
29+
echo No changes to files in $deploy_directory. Skipping commit.
30+
fi
31+
32+
git checkout $previous_branch --force

0 commit comments

Comments
 (0)