gogs配置钩子脚本,代码自动更新

2025-10-03 18:42:03

1、打开仓库设置中的管理git钩子,通过配置post-receive(提交后执行)来进行自动代码更新,并自动clone项目

gogs配置钩子脚本,代码自动更新

2、在钩子文本中配置,之后每次push提交都会被触发

gogs配置钩子脚本,代码自动更新

3、#!/bin/bash

root_path='/www/xiaochengxu/project'

unset $(git rev-parse --local-env-vars);

mkdir -p $root_path

cd $root_path;

git clone git@ssh.gogs.com:xiaochengxu/project.git $root_path

if [ $? = 0 ]; then

   chown -R 1000:100 $root_path && chmod -Rf g+s $root_path && chmod -R 775 $root_path

fi

git checkout .;

git pull origin master;

gogs配置钩子脚本,代码自动更新

4、最终代码自动生成到指定的root_path目录

gogs配置钩子脚本,代码自动更新

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢