mirror of
https://github.com/dokku/dokku.git
synced 2025-12-25 16:29:30 +01:00
This removes the need for two distinct users. Git pushes and dokku commands are sent using the same user.
40 lines
809 B
Bash
Executable File
40 lines
809 B
Bash
Executable File
#!/bin/bash
|
|
set -e;
|
|
|
|
case "$1" in
|
|
git-hook)
|
|
APP=$2
|
|
|
|
while read oldrev newrev refname
|
|
do
|
|
# Only run this script for the master branch. You can remove this
|
|
# if block if you wish to run it for others as well.
|
|
if [[ $refname = "refs/heads/master" ]] ; then
|
|
git archive $newrev | dokku receive $APP
|
|
fi
|
|
|
|
done
|
|
;;
|
|
|
|
git-*)
|
|
APP="$(echo $2 | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g')"
|
|
APP_PATH=$HOME/$APP
|
|
|
|
if [[ $1 == "git-receive-pack" && ! -d $APP_PATH ]]; then
|
|
git init --bare $APP_PATH > /dev/null
|
|
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
|
|
cat > $PRERECEIVE_HOOK <<EOF
|
|
#!/bin/bash
|
|
cat | dokku git-hook $APP
|
|
EOF
|
|
chmod +x $PRERECEIVE_HOOK
|
|
fi
|
|
|
|
args=$@
|
|
git-shell -c "$args"
|
|
;;
|
|
|
|
esac
|
|
cat
|
|
|