diff --git a/deploy.sh b/deploy.sh index d52a263..141476e 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,5 +1,42 @@ #!/usr/bin/env bash set -o errexit #abort if any command fails +me=$(basename "$0") + +read -r -d '' "help_message" <] + +Options: + + -h, --help Show this help information. + -v, --verbose Increase verbosity. Useful for debugging. + -e, --allow-empty Allow deployment of an empty directory. + -m, --message MESSAGE Specify the message used when committing on the + deploy branch. + -n, --no-hash Don't append the source commit's hash to the deploy + commit's message. + -c, --config-file PATH Override default & environment variables' values + with those in set in the file at 'PATH'. + +Variables: + + * GIT_DEPLOY_DIR Folder path containing the files to deploy. + * GIT_DEPLOY_BRANCH Commit deployable files to this branch. + * GIT_DEPLOY_REPO Push the deploy branch to this repository. + +These variables have default values defined in the script. The defaults can be +overridden by environment variables. Any environment variables are overridden +by values set in a '.env' file (if it exists), and in turn by those set in a +file specified by the '--config-file' option. +EOF + +print_help() { + printf "%s\n" "$help_message" +} main() { # Set args from a local environment file. @@ -12,7 +49,10 @@ main() { # Parse arg flags while : ; do - if [[ $1 = "-v" || $1 = "--verbose" ]]; then + if [[ $1 = "-h" || $1 = "--help" ]]; then + print_help + return 0 + elif [[ $1 = "-v" || $1 = "--verbose" ]]; then verbose=true shift elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then diff --git a/readme.md b/readme.md index 38e3d02..7b449ed 100644 --- a/readme.md +++ b/readme.md @@ -37,6 +37,8 @@ Do this every time you want to deploy, or have your CI server do it. 5. run `./deploy.sh` ### options +`-h`, `--help`: show the program's help info. + `-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. `-m`, `--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: '.