Accept first pushed branch as deploy-branch
And set to DOKKU_DEPLOY_BRANCH. Idea from https://github.com/dokku/dokku/pull/4167#issuecomment-717607136
This commit is contained in:
@@ -139,12 +139,15 @@ cmd-git-hook() {
|
|||||||
# if block if you wish to run it for others as well.
|
# if block if you wish to run it for others as well.
|
||||||
if [[ $refname == "refs/heads/${DOKKU_DEPLOY_BRANCH}" ]]; then
|
if [[ $refname == "refs/heads/${DOKKU_DEPLOY_BRANCH}" ]]; then
|
||||||
# broken out into plugin so we might support other methods to receive an app
|
# broken out into plugin so we might support other methods to receive an app
|
||||||
# shellcheck disable=SC2086
|
|
||||||
git_receive_app "$APP" "$newrev"
|
git_receive_app "$APP" "$newrev"
|
||||||
else
|
else
|
||||||
if [[ $(find "$PLUGIN_PATH"/enabled/*/receive-branch 2>/dev/null | wc -l) != 1 ]]; then
|
if [[ $(find "$PLUGIN_PATH"/enabled/*/receive-branch 2>/dev/null | wc -l) != 1 ]]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
plugn trigger receive-branch $APP $newrev $refname
|
plugn trigger receive-branch $APP $newrev $refname
|
||||||
|
elif [[ -z "$(fn-git-deploy-branch "$APP" "")" ]]; then
|
||||||
|
echo $'\e[1G\e[K'"-----> Set ${refname/refs\/heads\//} to DOKKU_DEPLOY_BRANCH."
|
||||||
|
fn-plugin-property-write "git" "$app" "deploy-branch" "${refname/refs\/heads\//}"
|
||||||
|
git_receive_app "$APP" "$newrev"
|
||||||
else
|
else
|
||||||
echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to ${DOKKU_DEPLOY_BRANCH}."
|
echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to ${DOKKU_DEPLOY_BRANCH}."
|
||||||
echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\//}:${DOKKU_DEPLOY_BRANCH}'"
|
echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\//}:${DOKKU_DEPLOY_BRANCH}'"
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ fn-git-last-updated-at() {
|
|||||||
fn-git-deploy-branch() {
|
fn-git-deploy-branch() {
|
||||||
declare desc="retrieve the deploy branch for a given application"
|
declare desc="retrieve the deploy branch for a given application"
|
||||||
local APP="$1"
|
local APP="$1"
|
||||||
|
local DEFAULT_BRANCH="${2-master}"
|
||||||
|
|
||||||
local DOKKU_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "$APP" "deploy-branch" "")"
|
local DOKKU_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "$APP" "deploy-branch" "")"
|
||||||
local DOKKU_GLOBAL_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "--global" "deploy-branch" "")"
|
local DOKKU_GLOBAL_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "--global" "deploy-branch" "")"
|
||||||
@@ -93,6 +94,6 @@ fn-git-deploy-branch() {
|
|||||||
elif [[ -n "$DOKKU_GLOBAL_DEPLOY_BRANCH" ]]; then
|
elif [[ -n "$DOKKU_GLOBAL_DEPLOY_BRANCH" ]]; then
|
||||||
echo "$DOKKU_GLOBAL_DEPLOY_BRANCH"
|
echo "$DOKKU_GLOBAL_DEPLOY_BRANCH"
|
||||||
else
|
else
|
||||||
echo "master"
|
echo "$DEFAULT_BRANCH"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
5
tests.mk
5
tests.mk
@@ -182,6 +182,10 @@ deploy-test-checks-root:
|
|||||||
@echo deploying checks-root app...
|
@echo deploying checks-root app...
|
||||||
cd tests && ./test_deploy ./apps/checks-root dokku.me '' true
|
cd tests && ./test_deploy ./apps/checks-root dokku.me '' true
|
||||||
|
|
||||||
|
deploy-test-main-branch:
|
||||||
|
@echo deploying checks-root app to main branch...
|
||||||
|
cd tests && ./test_deploy ./apps/checks-root dokku.me '' true main
|
||||||
|
|
||||||
deploy-test-clojure:
|
deploy-test-clojure:
|
||||||
@echo deploying config app...
|
@echo deploying config app...
|
||||||
cd tests && ./test_deploy ./apps/clojure dokku.me
|
cd tests && ./test_deploy ./apps/clojure dokku.me
|
||||||
@@ -253,6 +257,7 @@ deploy-test-static:
|
|||||||
deploy-tests:
|
deploy-tests:
|
||||||
@echo running deploy tests...
|
@echo running deploy tests...
|
||||||
@$(QUIET) $(MAKE) deploy-test-checks-root
|
@$(QUIET) $(MAKE) deploy-test-checks-root
|
||||||
|
@$(QUIET) $(MAKE) deploy-test-main-branch
|
||||||
@$(QUIET) $(MAKE) deploy-test-go-fail-predeploy
|
@$(QUIET) $(MAKE) deploy-test-go-fail-predeploy
|
||||||
@$(QUIET) $(MAKE) deploy-test-go-fail-postdeploy
|
@$(QUIET) $(MAKE) deploy-test-go-fail-postdeploy
|
||||||
@$(QUIET) $(MAKE) deploy-test-config
|
@$(QUIET) $(MAKE) deploy-test-config
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ APP="$1"
|
|||||||
TARGET="$2"
|
TARGET="$2"
|
||||||
FORWARDED_PORT="$3"
|
FORWARDED_PORT="$3"
|
||||||
SHOULD_FAIL="$4"
|
SHOULD_FAIL="$4"
|
||||||
|
BRANCH="${5:-master}"
|
||||||
REMOTE="dokku@$TARGET"
|
REMOTE="dokku@$TARGET"
|
||||||
REPO="test-$(basename "$APP")-$RANDOM"
|
REPO="test-$(basename "$APP")-$RANDOM"
|
||||||
|
|
||||||
@@ -43,9 +44,9 @@ git add .
|
|||||||
[[ -x pre-commit ]] && ./pre-commit "$REMOTE" "$REPO"
|
[[ -x pre-commit ]] && ./pre-commit "$REMOTE" "$REPO"
|
||||||
git commit -m 'initial commit'
|
git commit -m 'initial commit'
|
||||||
if [[ "$SHOULD_FAIL" == true ]]; then
|
if [[ "$SHOULD_FAIL" == true ]]; then
|
||||||
git push target master && succeeded git-push
|
git push target "master:$BRANCH" && succeeded git-push
|
||||||
else
|
else
|
||||||
git push target master || failed git-push
|
git push target "master:$BRANCH" || failed git-push
|
||||||
fi
|
fi
|
||||||
if [[ -x post-deploy ]]; then
|
if [[ -x post-deploy ]]; then
|
||||||
./post-deploy "$REMOTE" "$REPO" || failed post-deploy
|
./post-deploy "$REMOTE" "$REPO" || failed post-deploy
|
||||||
|
|||||||
Reference in New Issue
Block a user