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

31 lines
709 B
Bash
Executable File

#!/bin/bash
set -e
if [ "$#" -eq "0" ]; then
exit 1
fi
projectName=$1
repoDir="/var/lib/git/$projectName"
srcDir="/tmp/vn-repo/$projectName/src"
logDir="$HOME/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"
git --work-tree="$srcDir" --git-dir="$repoDir" checkout -f
if [ -f "$srcDir/deploy" ]; then
(cd "$srcDir" && "$srcDir/deploy" >> "$logFile" 2>&1)
fi
echo -e "\n# Deploying ended\n" >> "$logFile"