You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$?
76
81
set -o errexit
77
82
case$diffin
78
83
0) echo No changes to files in$deploy_directory. Skipping commit.;;
79
-
1)
80
-
set_user_id
81
-
git --work-tree "$deploy_directory" commit -m \
82
-
"publish: $commit_title"$'\n\n'"generated from commit $commit_hash"
83
-
84
-
disable_expanded_output
85
-
#--quiet is important here to avoid outputting the repo URL, which may contain a secret token
86
-
git push --quiet $repo$deploy_branch
87
-
enable_expanded_output
88
-
;;
84
+
1) commit+push;;
89
85
*)
90
86
echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2
91
87
return$diff
92
88
;;
93
89
esac
90
+
}
94
91
95
-
restore_head
92
+
commit+push() {
93
+
set_user_id
94
+
git --work-tree "$deploy_directory" commit -m \
95
+
"publish: $commit_title"$'\n\n'"generated from commit $commit_hash"
96
+
97
+
disable_expanded_output
98
+
#--quiet is important here to avoid outputting the repo URL, which may contain a secret token
99
+
git push --quiet $repo$deploy_branch
100
+
enable_expanded_output
96
101
}
97
102
98
103
#echo expanded commands as they are executed (for debugging)
Copy file name to clipboardExpand all lines: readme.md
-5Lines changed: 0 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,6 @@ Download the script (`wget https://github.com/X1011/git-directory-deploy/raw/mas
12
12
-**default_username**, **default_email**: identity to use for git commits if none is set already. Useful for CI servers.
13
13
-**repo**: repository to deploy to. Must be readable and writable. The default of "origin" will not work on Travis CI, since it uses the read-only git protocol. In that case, it is recommended to store a [GitHub token](https://help.github.com/articles/creating-an-access-token-for-command-line-use) in a [secure environment variable](http://docs.travis-ci.com/user/environment-variables/#Secure-Variables) and use it in an HTTPS URL like this: <code>repo=https://$GITHUB_TOKEN@github\.com/<i>user</i>/<i>repo</i>.git</code>
14
14
15
-
## setup
16
-
Ensure configuration variables are correct in `deploy.sh` and run `./deploy.sh -s`
17
-
18
15
## run
19
16
Do this every time you want to deploy, or have your CI server do it.
20
17
@@ -27,6 +24,4 @@ Do this every time you want to deploy, or have your CI server do it.
27
24
### options
28
25
`-v`, `--verbose`: echo expanded commands as they are executed, using the xtrace option. This can be useful for debugging, as the output will include the values of variables that are being used, such as $commit_title and $deploy_directory. However, the script makes special effort to not output the value of $repo, as it may contain a secret authentication token.
29
26
30
-
`-s`, `--setup`: perform one-time setup to prepare the repo for deployments. Creates `deploy_branch`, initializes it with the contents of `deploy_directory`, and pushes it to `repo`.
31
-
32
27
`-e`, `--allow-empty`: allow deployment of an empty directory. By default, the script will abort if `deploy_directory` is empty.
0 commit comments