This repository has been archived on 2020-01-17. You can view files and clone it, but cannot push or open issues or pull requests.
vn-repo/vn-branch

49 lines
998 B
Bash
Executable File

#!/bin/bash
set -e
if [ "$#" -eq "0" ]; then
exit 1
fi
projectName=$1
gitBranch=$2
. /etc/vn-repo/config
if [ -z "$gitUrl" ]; then
gitUrl=http://localhost
fi
if [ -z "$gitBranch" ]; then
gitBranch=master
fi
repoDir="/var/lib/git/$projectName"
srcDir="/tmp/vn-repo/$projectName/src"
logDir="/usr/share/vn-repo/web/logs"
logFile="$logDir/$projectName.out"
mkdir -p "$logDir"
rm -f "$logFile"
echo -e "\n# Deploying started\n" >> "$logFile"
echo " * Date: $(date)" >> "$logFile"
echo " * Project: $projectName" >> "$logFile"
echo " * Directory: $srcDir" >> "$logFile"
echo " * Host: $(hostname)" >> "$logFile"
mkdir -p "$srcDir"
cd "$srcDir"
if [ ! -d "$srcDir/.git" ]; then
git init >> "$logFile"
fi
git config remote.origin.url "$gitUrl/$projectName" >> "$logFile"
git pull origin "$gitBranch" >> "$logFile"
if [ -f "$srcDir/deploy" ]; then
"$srcDir/deploy" >> "$logFile" 2>&1
fi
echo -e "\n# Deploying ended\n" >> "$logFile"