File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments