blob: 6ee3a1795f2321a4fe49abe9a6cf4d7ab9866714 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
|