@@ -4,9 +4,22 @@ set -e #abort if any command fails
4
4
deploy_directory=dist
5
5
deploy_branch=gh-pages
6
6
7
+ # if no user identity is already set in the current git environment, use this:
8
+ default_username=deploy.sh
9
+ default_email=XX1011+$default_user @gmail.com
10
+
7
11
commit_title=` git log -n 1 --format=" %s" HEAD`
8
12
commit_hash=` git log -n 1 --format=" %H" HEAD`
9
13
14
+ set_user_id () {
15
+ if [[ -z ` git config user.name` ]]; then
16
+ git config user.name " $default_username "
17
+ fi
18
+ if [[ -z ` git config user.email` ]]; then
19
+ git config user.email " $default_email "
20
+ fi
21
+ }
22
+
10
23
previous_branch=` git rev-parse --abbrev-ref HEAD`
11
24
if [[ $previous_branch = " HEAD" ]]; then
12
25
previous_branch=$commit_hash
@@ -18,15 +31,16 @@ if ! ( git diff --exit-code --quiet \
18
31
exit 1
19
32
fi
20
33
21
- git --work-tree $deploy_directory checkout $deploy_branch --force
22
- git --work-tree $deploy_directory add --all
34
+ git --work-tree " $deploy_directory " checkout $deploy_branch --force
35
+ git --work-tree " $deploy_directory " add --all
23
36
24
- if git --work-tree $deploy_directory diff --exit-code --quiet HEAD; then
25
- git --work-tree $deploy_directory commit -m \
37
+ if git --work-tree " $deploy_directory " diff --exit-code --quiet HEAD; then
38
+ echo No changes to files in $deploy_directory . Skipping commit.
39
+ else
40
+ set_user_id
41
+ git --work-tree " $deploy_directory " commit -m \
26
42
" publish: $commit_title " $' \n\n ' " generated from commit $commit_hash "
27
43
git push origin $deploy_branch
28
- else
29
- echo No changes to files in $deploy_directory . Skipping commit.
30
44
fi
31
45
32
46
git checkout $previous_branch --force
0 commit comments