Dienstag, 31. März 2015

Push to deploy

Die einfachste Variante Git Push to deploy einzurichten:

Auf dem Deploy Server(setup_deploy_server.sh):

DEPLOY_DIR=$1
PROJECT_NAME=$2 
cd $DEPLOY_DIR
git init --bare ${PROJECT_NAME}.git
mkdir $PROJECT_NAME
cat <<EOF > ${PROJECT_NAME}.git/hooks/post-update
#!/bin/sh
if [[ "\$3" != "master" ]]
then
    echo "Received branch \$3, not deploying."
    exit
fi
GIT_WORK_TREE="${DEPLOY_DIR}/${PROJECT_NAME}" git checkout -f master
EOF
chmod +x ${PROJECT_NAME}.git/hooks/post-update

Auf dem Dev Rechner im Git Repo

git remote add deploy ssh://deploy_server/${DEPLOY_DIR}/${PROJECT_NAME}.git
git push deploy master

Keine Kommentare:

Kommentar veröffentlichen