From 52542136cf4d791c5c5ce81ad7794724a59827d0 Mon Sep 17 00:00:00 2001 From: Andre Marcelo-Tanner Date: Sat, 30 Apr 2016 14:59:41 +0800 Subject: [PATCH 1/5] Configuration output command Added `mkconfig` command. deploy mkconfig stage --user visionmedia --host server-ip-address.com --repo git@github.com/visionmedia/deploy.git --path /home/deploy --ref origin/master --post-deploy ./bin/post-deploy [stage] user=visionmedia host=server-ip-address.com repo=git@github.com/visionmedia/deploy.git path=/home/deploy ref=origin/master post_deploy=./bin/post-deploy --- Readme.md | 1 + bin/deploy | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/Readme.md b/Readme.md index f0ce18b..4bb0ae5 100644 --- a/Readme.md +++ b/Readme.md @@ -32,6 +32,7 @@ prev[ious] output previous release commit exec|run execute the given 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 diff --git a/bin/deploy b/bin/deploy index 45fe3fa..88d3bd8 100755 --- a/bin/deploy +++ b/bin/deploy @@ -337,6 +337,58 @@ update() { && log "updated $VERSION -> `./bin/deploy --version`" } +# +# Output config +# + +mkconfig() { + local user="ssh-user" + local host="your-server.com" + local repo="git@github.com/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 ;; + --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$forward_agent$needs_tty$pre_deploy$post_deploy$test +EOF +} + # parse argv while test $# -ne 0; do @@ -356,6 +408,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; From b7a2ef367b1f3e3c36fca6ac04d231cd27434d3f Mon Sep 17 00:00:00 2001 From: Andre Marcelo-Tanner Date: Sat, 30 Apr 2016 16:12:08 +0800 Subject: [PATCH 2/5] updated help command instructions --- bin/deploy | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/deploy b/bin/deploy index 88d3bd8..d124023 100755 --- a/bin/deploy +++ b/bin/deploy @@ -41,6 +41,7 @@ usage() { prev[ious] output previous release commit exec|run execute the given 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 From 1f04ebfbbbf825880d9c8e4c3e5bb2aaa4ca01c4 Mon Sep 17 00:00:00 2001 From: Andre Marcelo-Tanner Date: Sat, 30 Apr 2016 21:01:09 +0800 Subject: [PATCH 3/5] fix bug with mkconfig --- bin/deploy | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/deploy b/bin/deploy index d124023..66bc3d7 100755 --- a/bin/deploy +++ b/bin/deploy @@ -356,19 +356,19 @@ mkconfig() { --repo) test -n "$1" && repo=$1; shift ;; --path) test -n "$1" && path=$1; shift ;; --forward-agent) test -n "$1" && local forward_agent=" -forward-agent=$1"; shift ;; +forward-agent $1"; shift ;; --needs-tty) test -n "$1" && local needs_tty=" -needs_tty=$1"; shift ;; +needs_tty $1"; shift ;; -P|--port) test -n "$1" && local port=" -port=$1"; shift ;; +port $1"; shift ;; --ref) test -n "$1" && local ref=" -ref=$1"; shift ;; +ref $1"; shift ;; --pre-deploy) test -n "$1" && local pre_deploy=" -pre_deploy=$1"; shift ;; +pre_deploy $1"; shift ;; --post-deploy) test -n "$1" && local post_deploy=" -post_deploy=$1"; shift ;; +post_deploy $1"; shift ;; --test) test -n "$1" && local test=" -test=$1"; shift ;; +test $1"; shift ;; *) if test -z "$config_name"; then local config_name=$arg; @@ -383,10 +383,10 @@ test=$1"; shift ;; cat <<-EOF [$config_name] -user=$user -host=$host$port -repo=$repo -path=$path$ref$forward_agent$needs_tty$pre_deploy$post_deploy$test +user $user +host $host$port +repo $repo +path $path$ref$forward_agent$needs_tty$pre_deploy$post_deploy$test EOF } From fecd166174dcdc45dded31ab4abde2984fe9818d Mon Sep 17 00:00:00 2001 From: Andre Marcelo-Tanner Date: Sun, 1 May 2016 09:38:13 +0800 Subject: [PATCH 4/5] fixing hook names --- bin/deploy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/deploy b/bin/deploy index 66bc3d7..600a637 100755 --- a/bin/deploy +++ b/bin/deploy @@ -364,9 +364,9 @@ port $1"; shift ;; --ref) test -n "$1" && local ref=" ref $1"; shift ;; --pre-deploy) test -n "$1" && local pre_deploy=" -pre_deploy $1"; shift ;; +pre-deploy $1"; shift ;; --post-deploy) test -n "$1" && local post_deploy=" -post_deploy $1"; shift ;; +post-deploy $1"; shift ;; --test) test -n "$1" && local test=" test $1"; shift ;; *) From 95e12bf7df68d38fa4c318ae33b5d283646fcd71 Mon Sep 17 00:00:00 2001 From: Andre Marcelo-Tanner Date: Tue, 17 May 2016 07:42:55 +0800 Subject: [PATCH 5/5] adding key to mkconfig --- bin/deploy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/deploy b/bin/deploy index 600a637..4402c95 100755 --- a/bin/deploy +++ b/bin/deploy @@ -355,6 +355,8 @@ mkconfig() { -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=" @@ -386,7 +388,7 @@ test $1"; shift ;; user $user host $host$port repo $repo -path $path$ref$forward_agent$needs_tty$pre_deploy$post_deploy$test +path $path$ref$key$forward_agent$needs_tty$pre_deploy$post_deploy$test EOF }