一段纯sh脚本,自动git pull

发表:2020-01-13 09:55:05

#!/bin/bash
DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
date=`date '+%Y-%m-%d %T'`
echo ${date}
cd /data/wwwroot/students-carnie/students-carnie
headId=`git rev-parse --short HEAD`
echo ${DIR}
git pull >> ${DIR}/students.log
headId2=`git rev-parse --short HEAD`
if [ $headId == $headId2 ]
then
   echo $headId " -- " $headId2
   echo "no pull " 
   exit;
else
   echo "deploy ..."
   php server refreshdockerfile
   sh ./deploy.sh
   sh /data/wwwroot/students-carnie/sh/docker-compose.sh
   echo ${date} >>${DIR}/gitpull_finsh.log
fi
You have new mail in /var/spool/mail/root


相关文章