Skip to content

Commit 376df79

Browse files
committed
default user identity for deploy script,
commit deploy directory when there *are* changes, not when there are no changes (>_<)
1 parent 3042954 commit 376df79

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

deploy.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@ set -e #abort if any command fails
44
deploy_directory=dist
55
deploy_branch=gh-pages
66

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+
711
commit_title=`git log -n 1 --format="%s" HEAD`
812
commit_hash=`git log -n 1 --format="%H" HEAD`
913

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+
1023
previous_branch=`git rev-parse --abbrev-ref HEAD`
1124
if [[ $previous_branch = "HEAD" ]]; then
1225
previous_branch=$commit_hash
@@ -18,15 +31,16 @@ if ! ( git diff --exit-code --quiet \
1831
exit 1
1932
fi
2033

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
2336

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 \
2642
"publish: $commit_title"$'\n\n'"generated from commit $commit_hash"
2743
git push origin $deploy_branch
28-
else
29-
echo No changes to files in $deploy_directory. Skipping commit.
3044
fi
3145

3246
git checkout $previous_branch --force

0 commit comments

Comments
 (0)