diff options
| author | danix <danix@danix.xyz> | 2018-12-19 08:16:14 +0100 |
|---|---|---|
| committer | danix <danix@danix.xyz> | 2018-12-19 08:16:14 +0100 |
| commit | d96d4d16706f295af4f5e1df201a683606f2f108 (patch) | |
| tree | e60cd582f956f0526b81507514e8583bcfa3b058 /gitbase | |
| parent | 13686e1e2076b534b87b66489ad177cd11d5d93a (diff) | |
| download | git_shell-d96d4d16706f295af4f5e1df201a683606f2f108.tar.gz git_shell-d96d4d16706f295af4f5e1df201a683606f2f108.zip | |
extra scripts are now separated from main create script.
Diffstat (limited to 'gitbase')
| -rw-r--r-- | gitbase/deploy.sh | 31 | ||||
| -rw-r--r-- | gitbase/pip_install | 14 | ||||
| -rw-r--r-- | gitbase/post-receive | 3 | ||||
| -rw-r--r-- | gitbase/post-receive-py | 4 |
4 files changed, 52 insertions, 0 deletions
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 diff --git a/gitbase/pip_install b/gitbase/pip_install new file mode 100644 index 0000000..07a6374 --- /dev/null +++ b/gitbase/pip_install @@ -0,0 +1,14 @@ +#!/bin/sh +while read oldrev newrev refname; do + if [[ $refname =~ .*/master$ ]]; then + # definitely updating master; + CHECKFILE=$(git ls-tree --full-tree -r HEAD |grep requirements.txt |awk '{print $3}') + TMPREQ=$(git cat-file -p $CHECKFILE > /tmp/{{PROJECT}}-req.txt) + if [ $CHECKFILE ]; then + {{VENVSDIR}}/{{PROJECT}}/bin/pip install -r /tmp/{{PROJECT}}-req.txt + fi + if git diff-tree --name-only -r -z $oldrev $newrev $CHECKFILE; then + {{VENVSDIR}}/{{PROJECT}}/bin/pip install -r /tmp/{{PROJECT}}-req.txt + fi + fi +done diff --git a/gitbase/post-receive b/gitbase/post-receive new file mode 100644 index 0000000..d9da8cb --- /dev/null +++ b/gitbase/post-receive @@ -0,0 +1,3 @@ +#!/bin/sh +/usr/bin/pee {{GITDIR}}/{{PROJECT}}.git/custom-hooks/deploy.sh \ + {{GITDIR}}/{{PROJECT}}.git/custom-hooks/git_multimail.py diff --git a/gitbase/post-receive-py b/gitbase/post-receive-py new file mode 100644 index 0000000..37ac6cf --- /dev/null +++ b/gitbase/post-receive-py @@ -0,0 +1,4 @@ +#!/bin/sh +/usr/bin/pee {{GITDIR}}/{{PROJECT}}.git/custom-hooks/deploy.sh \ + {{GITDIR}}/{{PROJECT}}.git/custom-hooks/pip_install \ + {{GITDIR}}/{{PROJECT}}.git/custom-hooks/git_multimail.py |
