Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration output command #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
prev[ious] output previous release commit
exec|run <cmd> execute the given <cmd>
console open an ssh session to the host
mkconfig outputs a configuration from the arguments given so you can save it to a file
list list previous deploy commits
[ref] deploy to [ref], the 'ref' setting, or latest tag

Expand Down
56 changes: 56 additions & 0 deletions bin/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ usage() {
prev[ious] output previous release commit
exec|run <cmd> execute the given <cmd>
console open an ssh session to the host
mkconfig outputs a configuration from the arguments given so you can save it to a file
list list previous deploy commits
[ref] deploy to [ref], the 'ref' setting, or latest tag

Expand Down Expand Up @@ -337,6 +338,60 @@ update() {
&& log "updated $VERSION -> `./bin/deploy --version`"
}

#
# Output config
#

mkconfig() {
local user="ssh-user"
local host="your-server.com"
local repo="[email protected]/visionmedia/deploy.git"
local path="/remote/path/to/site"

while test $# -ne 0; do
arg=$1; shift
case $arg in
-u|--user) test -n "$1" && user=$1; shift ;;
-h|--host) test -n "$1" && host=$1; shift ;;
--repo) test -n "$1" && repo=$1; shift ;;
--path) test -n "$1" && path=$1; shift ;;
-i|--key) test -n "$1" && local key="
key $1"; shift ;;
--forward-agent) test -n "$1" && local forward_agent="
forward-agent $1"; shift ;;
--needs-tty) test -n "$1" && local needs_tty="
needs_tty $1"; shift ;;
-P|--port) test -n "$1" && local port="
port $1"; shift ;;
--ref) test -n "$1" && local ref="
ref $1"; shift ;;
--pre-deploy) test -n "$1" && local pre_deploy="
pre-deploy $1"; shift ;;
--post-deploy) test -n "$1" && local post_deploy="
post-deploy $1"; shift ;;
--test) test -n "$1" && local test="
test $1"; shift ;;
*)
if test -z "$config_name"; then
local config_name=$arg;
fi
;;
esac
done

if test -z "$config_name"; then
local config_name="CONFIG_NAME"
fi

cat <<-EOF
[$config_name]
user $user
host $host$port
repo $repo
path $path$ref$key$forward_agent$needs_tty$pre_deploy$post_deploy$test
EOF
}

# parse argv

while test $# -ne 0; do
Expand All @@ -356,6 +411,7 @@ while test $# -ne 0; do
list) require_env; list_deploys; exit ;;
update) update; exit ;;
config) config $@; exit ;;
mkconfig) mkconfig $@; exit ;;
*)
if test -z "$ENV"; then
ENV=$arg;
Expand Down