Created
May 11, 2018 11:11
-
-
Save amon-ra/46409526aa3a4cadb308b67fba68d215 to your computer and use it in GitHub Desktop.
ISPCONFIG gitea hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
#gitea-ispconfig: https://gist.github.com/amon-ra/3b242d7d1dc829152ca00c92714e42cc | |
echo "---------------------" >> /tmp/gitea_ispconfig.log | |
if [ $(git rev-parse --is-bare-repository) = true ] | |
then | |
REPOSITORY_BASENAME=$(basename "$PWD") | |
REPOSITORY_DIR=$PWD | |
else | |
REPOSITORY_BASENAME=$(basename $(readlink -nf "$PWD"/..)) | |
REPOSITORY_DIR=$(readlink -nf "$PWD"/..) | |
fi | |
REPOSITORY_BASENAME=${REPOSITORY_BASENAME%.git} | |
echo $REPOSITORY_BASENAME $REPOSITORY_DIR >> /tmp/gitea_ispconfig.log | |
while read oldrev newrev ref | |
do | |
echo $read $oldrev $newrev $ref >> /tmp/gitea_ispconfig.log | |
branch=`echo $ref | cut -d/ -f3` | |
if [ "master" == "$branch" ]; then | |
if [ -d "/var/www/$REPOSITORY_BASENAME/web" ]; then | |
#git --work-tree=/var/www/$REPOSITORY_BASENAME/web --git-dir=$REPOSITORY_DIR checkout -f | |
sudo /usr/local/sbin/gitea-ispconfig /var/www/$REPOSITORY_BASENAME/web $REPOSITORY_DIR | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment