X-Git-Url: https://git.danix.xyz/?p=git_shell.git;a=blobdiff_plain;f=gitbase%2Fdeploy.sh;fp=gitbase%2Fdeploy.sh;h=6ee3a1795f2321a4fe49abe9a6cf4d7ab9866714;hp=0000000000000000000000000000000000000000;hb=d96d4d16706f295af4f5e1df201a683606f2f108;hpb=13686e1e2076b534b87b66489ad177cd11d5d93a diff --git a/gitbase/deploy.sh b/gitbase/deploy.sh new file mode 100644 index 0000000..6ee3a17 --- /dev/null +++ b/gitbase/deploy.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Directory where to deploy files from repository +DPTARGET="" +# Directory containing repository +DPGIT_DIR="{{GITDIR}}/{{PROJECT}}.git" +# Branch that is going to be deployed to server +DPBRANCH="master" + +while read oldrev newrev ref +do + # if DPTARGET is empty we don't want deploy for this project + if [[ ! "" == $DPTARGET ]]; then + # let's check that we are deploying to the correct branch + if [[ $ref = refs/heads/${DPBRANCH} ]]; then + echo "Ref $ref received. Deploying ${DPBRANCH} branch to production..." + git --work-tree=$DPTARGET --git-dir=$DPGIT_DIR checkout -f $DPBRANCH + NOW=$(date +"%d%m%Y-%H%M") + git tag release_$NOW $DPBRANCH + echo " /===============================" + echo " | DEPLOYMENT COMPLETED" + echo " | Target branch: $DPTARGET" + echo " | Target folder: $DPGIT_DIR" + echo " | Tag name : release_$NOW" + echo " \==============================" + else + echo "Ref $ref received. Doing nothing: only the ${DPBRANCH} branch may be deployed on this server." + fi + else + echo "Target directory not declared. Skipping deploy to server." + fi +done