Merge pull request #3091 from dokku/3047-detect-deploy-method

Properly trigger tar-based deploys on git-deployed repositories
This commit is contained in:
Jose Diaz-Gonzalez
2018-03-03 21:36:11 -05:00
committed by GitHub
11 changed files with 110 additions and 44 deletions

22
plugins/git/deploy-source Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
git_deploy_source() {
declare desc="git deploy-source plugin trigger"
declare trigger="git_deploy_source"
declare APP="$1"
local STDIN
STDIN=$(cat)
# bail if another source is detected
if [[ -n "$STDIN" ]]; then
echo "$STDIN"
return
fi
if [[ -d "$DOKKU_ROOT/$APP/refs" ]]; then
echo "git"
fi
}
git_deploy_source "$@"

View File

@@ -147,7 +147,7 @@ git_hook_cmd() {
if [[ $refname = "refs/heads/${DOKKU_DEPLOY_BRANCH}" ]]; then
# broken out into plugin so we might support other methods to receive an app
# shellcheck disable=SC2086
plugn trigger receive-app $APP $newrev
git_receive_app "$APP" "$newrev"
else
if [[ $(find "$PLUGIN_PATH"/enabled/*/receive-branch 2>/dev/null | wc -l) != 0 ]]; then
# shellcheck disable=SC2086
@@ -175,6 +175,21 @@ git_build() {
git_build_app_repo $APP $REF
}
git_receive_app() {
declare desc="git receive-app plugin trigger"
declare APP="$1" REV="$2"
# Don't trigger git build if there is no git repository.
if [[ ! -d "$DOKKU_ROOT/$APP/refs" ]]; then
true
else
acquire_app_deploy_lock "$APP" "exclusive"
# shellcheck disable=SC2086
git_build $APP $REV
release_app_deploy_lock "$APP"
fi
}
git_upload_pack_cmd() {
declare desc="executes git-upload-pack"
declare cmd="git-upload-pack"

View File

@@ -1,22 +1,5 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/git/functions"
git_receive_app() {
declare desc="git receive-app plugin trigger"
local trigger="git_receive_app"
local APP="$1"; local REV="$2"
# Don't trigger git build if there is no git repository.
if [[ ! -d "$DOKKU_ROOT/$APP/refs" ]]; then
true
else
acquire_app_deploy_lock "$APP" "exclusive"
# shellcheck disable=SC2086
git_build $APP $REV
release_app_deploy_lock "$APP"
fi
}
git_receive_app "$@"