mirror of
https://github.com/danbulant/api_docs
synced 2026-06-24 00:51:56 +00:00
Fix incorrect documentation in deploy.sh
This commit is contained in:
parent
33515061b7
commit
e8e2e5e144
1 changed files with 8 additions and 27 deletions
35
deploy.sh
35
deploy.sh
|
|
@ -15,20 +15,7 @@ Options:
|
||||||
deploy branch.
|
deploy branch.
|
||||||
-n, --no-hash Don't append the source commit's hash to the deploy
|
-n, --no-hash Don't append the source commit's hash to the deploy
|
||||||
commit's message.
|
commit's message.
|
||||||
-c, --config-file PATH Override default & environment variables' values
|
"
|
||||||
with those in set in the file at 'PATH'. Must be the
|
|
||||||
first option specified.
|
|
||||||
|
|
||||||
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."
|
|
||||||
|
|
||||||
bundle exec middleman build --clean
|
bundle exec middleman build --clean
|
||||||
|
|
||||||
|
|
@ -38,12 +25,6 @@ parse_args() {
|
||||||
source .env
|
source .env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set args from file specified on the command-line.
|
|
||||||
if [[ $1 = "-c" || $1 = "--config-file" ]]; then
|
|
||||||
source "$2"
|
|
||||||
shift 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Parse arg flags
|
# Parse arg flags
|
||||||
# If something is exposed as an environment variable, set/overwrite it
|
# If something is exposed as an environment variable, set/overwrite it
|
||||||
# here. Otherwise, set/overwrite the internal variable instead.
|
# here. Otherwise, set/overwrite the internal variable instead.
|
||||||
|
|
@ -98,24 +79,24 @@ main() {
|
||||||
|
|
||||||
commit_title=`git log -n 1 --format="%s" HEAD`
|
commit_title=`git log -n 1 --format="%s" HEAD`
|
||||||
commit_hash=` git log -n 1 --format="%H" HEAD`
|
commit_hash=` git log -n 1 --format="%H" HEAD`
|
||||||
|
|
||||||
#default commit message uses last title if a custom one is not supplied
|
#default commit message uses last title if a custom one is not supplied
|
||||||
if [[ -z $commit_message ]]; then
|
if [[ -z $commit_message ]]; then
|
||||||
commit_message="publish: $commit_title"
|
commit_message="publish: $commit_title"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#append hash to commit message unless no hash flag was found
|
#append hash to commit message unless no hash flag was found
|
||||||
if [ $append_hash = true ]; then
|
if [ $append_hash = true ]; then
|
||||||
commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash"
|
commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
previous_branch=`git rev-parse --abbrev-ref HEAD`
|
previous_branch=`git rev-parse --abbrev-ref HEAD`
|
||||||
|
|
||||||
if [ ! -d "$deploy_directory" ]; then
|
if [ ! -d "$deploy_directory" ]; then
|
||||||
echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2
|
echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# must use short form of flag in ls for compatibility with OS X and BSD
|
# must use short form of flag in ls for compatibility with OS X and BSD
|
||||||
if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then
|
if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then
|
||||||
echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2
|
echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2
|
||||||
|
|
@ -124,7 +105,7 @@ main() {
|
||||||
|
|
||||||
if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then
|
if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then
|
||||||
# deploy_branch exists in $repo; make sure we have the latest version
|
# deploy_branch exists in $repo; make sure we have the latest version
|
||||||
|
|
||||||
disable_expanded_output
|
disable_expanded_output
|
||||||
git fetch --force $repo $deploy_branch:$deploy_branch
|
git fetch --force $repo $deploy_branch:$deploy_branch
|
||||||
enable_expanded_output
|
enable_expanded_output
|
||||||
|
|
@ -207,7 +188,7 @@ restore_head() {
|
||||||
else
|
else
|
||||||
git symbolic-ref HEAD refs/heads/$previous_branch
|
git symbolic-ref HEAD refs/heads/$previous_branch
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git reset --mixed
|
git reset --mixed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,4 +200,4 @@ sanitize() {
|
||||||
"$@" 2> >(filter 1>&2) | filter
|
"$@" 2> >(filter 1>&2) | filter
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ $1 = --source-only ]] || main "$@"
|
[[ $1 = --source-only ]] || main "$@"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue