git--gogs自动部署到web

1.先找到服务器仓库的地址

 

 新建post-receive文件

#!/usr/bin/env bash
"C:/python/gogs/gogs.exe" hook --config='C:/python/gogs/custom/conf/app.ini' post-receive

[python] view plain copy
#!/bin/sh

#author: embbnux
#Blog of Embbnux: http://www.embbnux.com

#判断是不是远端仓库
IS_BARE=$(git rev-parse --is-bare-repository)
if [ -z "$IS_BARE" ]; then
echo >&2 "fatal: post-receive: IS_NOT_BARE"
exit 1
fi

unset GIT_DIR
DeployPath="C:/python/platform_qa_test" //web端路劲

echo "==============================================="
cd $DeployPath
echo "deploying the test web"

#git stash
#git pull origin master
git fetch --all
git reset --hard origin/master

time=`date`
echo "web server pull at webserver at time: $time."
echo "================================================"

 IDE  push一次,就ok了

posted @ 2018-05-14 18:50  明天更好hjm  阅读(177)  评论(0编辑  收藏  举报