From 2ec8a51070f5a620fbd3ac09526903b96b249a9a Mon Sep 17 00:00:00 2001 From: Ric Harvey Date: Tue, 7 Feb 2017 10:36:43 +0000 Subject: [PATCH] merge in @royrico pull request into 7.1 code --- README.md | 1 + scripts/start.sh | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2fdb32e..8a1cc21 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ The following flags are a list of all the currently supported options that can b - **GIT_BRANCH** : Select a specific branch (optional) - **GIT_EMAIL** : Set your email for code pushing (required for git to work) - **GIT_NAME** : Set your name for code pushing (required for git to work) + - **GIT_USE_SSH** : Set this to 1 if you want to use git over SSH (instead of HTTP), useful if you want to use Bitbucket instead of GitHub - **SSH_KEY** : Private SSH deploy key for your repository base64 encoded (requires write permissions for pushing) - **GIT_PERSONAL_TOKEN** : Personal access token for your git account (required for HTTPS git access) - **GIT_USERNAME** : Git username for use with personal tokens. (required for HTTPS git access) diff --git a/scripts/start.sh b/scripts/start.sh index f1da4a8..1082291 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -34,19 +34,20 @@ if [ ! -d "/var/www/html/.git" ]; then if [ ! -z "$GIT_REPO" ]; then # Remove the test index file rm -Rf /var/www/html/* + GIT_COMMAND='git clone ' if [ ! -z "$GIT_BRANCH" ]; then - if [ -z "$GIT_USERNAME" ] && [ -z "$GIT_PERSONAL_TOKEN" ]; then - git clone -b $GIT_BRANCH $GIT_REPO /var/www/html/ || exit 1 - else - git clone -b ${GIT_BRANCH} https://${GIT_USERNAME}:${GIT_PERSONAL_TOKEN}@${GIT_REPO} /var/www/html || exit 1 - fi - else - if [ -z "$GIT_USERNAME" ] && [ -z "$GIT_PERSONAL_TOKEN" ]; then - git clone $GIT_REPO /var/www/html/ || exit 1 - else - git clone https://${GIT_USERNAME}:${GIT_PERSONAL_TOKEN}@${GIT_REPO} /var/www/html || exit 1 - fi + GIT_COMMAND=${GIT_COMMAND}" -b ${GIT_BRANCH}" fi + + if [ -z "$GIT_USERNAME" ] && [ -z "$GIT_PERSONAL_TOKEN" ]; then + GIT_COMMAND=${GIT_COMMAND}" ${GIT_REPO}" + else + if [[ "$GIT_USE_SSH" == "1" ]]; then + GIT_COMMAND=${GIT_COMMAND}" ${GIT_REPO}" + else + GIT_COMMAND=${GIT_COMMAND}" https://${GIT_USERNAME}:${GIT_PERSONAL_TOKEN}@${GIT_REPO}" + fi + ${GIT_COMMAND} /var/www/html || exit 1 chown -Rf nginx.nginx /var/www/html fi fi