Skip to content

Commit ca7cac1

Browse files
author
Matt Pearson
committed
Merge branch 'master' into feature/env-files
2 parents a1e762a + 25eae1c commit ca7cac1

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

deploy.sh

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
#!/usr/bin/env bash
22
set -o errexit #abort if any command fails
3+
me=$(basename "$0")
4+
5+
help_message="\
6+
Usage: $me [<options>]
7+
Deploy generated files to a git branch.
8+
9+
Options:
10+
11+
-h, --help Show this help information.
12+
-v, --verbose Increase verbosity. Useful for debugging.
13+
-e, --allow-empty Allow deployment of an empty directory.
14+
-m, --message MESSAGE Specify the message used when committing on the
15+
deploy branch.
16+
-n, --no-hash Don't append the source commit's hash to the deploy
17+
commit's message.
18+
-c, --config-file PATH Override default & environment variables' values
19+
with those in set in the file at 'PATH'.
20+
21+
Variables:
22+
23+
GIT_DEPLOY_DIR Folder path containing the files to deploy.
24+
GIT_DEPLOY_BRANCH Commit deployable files to this branch.
25+
GIT_DEPLOY_REPO Push the deploy branch to this repository.
26+
27+
These variables have default values defined in the script. The defaults can be
28+
overridden by environment variables. Any environment variables are overridden
29+
by values set in a '.env' file (if it exists), and in turn by those set in a
30+
file specified by the '--config-file' option."
331

432
parse_args() {
533
# Set args from a local environment file.
@@ -17,7 +45,10 @@ parse_args() {
1745
# If something is exposed as an environment variable, set/overwrite it
1846
# here. Otherwise, set/overwrite the internal variable instead.
1947
while : ; do
20-
if [[ $1 = "-v" || $1 = "--verbose" ]]; then
48+
if [[ $1 = "-h" || $1 = "--help" ]]; then
49+
echo "$help_message"
50+
return 0
51+
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
2152
verbose=true
2253
shift
2354
elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Do this every time you want to deploy, or have your CI server do it.
3737
5. run `./deploy.sh`
3838

3939
### options
40+
`-h`, `--help`: show the program's help info.
41+
4042
`-c`, `--config-file`: specify a file that overrides the script's default configuration, or those values set in `.env`. The syntax for this file should be normal `var=value` declarations.
4143

4244
`-m`, `--message <message>`: specify message to be used for the commit on `deploy_branch`. By default, the message is the title of the source commit, prepended with 'publish: '.

0 commit comments

Comments
 (0)