Coding添加WebHook

发布时间 2023-07-20 16:13:26作者: 悬剑丶

一、新增部署公钥

二、同步代码

三、更新目录权限

四、创建WebHook

 

#!/bin/bash
echo ""
#输出当前时间
date --date='0 days ago' "+%Y-%m-%d %H:%M:%S"
echo "Start"
#git项目路径
gitPath="/www/wwwroot/*****"
#git 网址
gitHttp="git@e.coding.net:*****"

echo "Web站点路径:$gitPath"

#判断项目路径是否存在
if [ -d "$gitPath" ]; then
        cd $gitPath
        echo "进去目录了"
        #判断是否存在git目录
        if [ ! -d ".git" ]; then
                echo "在该目录下克隆 git"
                git clone $gitHttp gittemp
                mv gittemp/.git .
                rm -rf gittemp
        fi
        echo "前往拉取"
        #拉取最新的项目文件
        git reset --hard origin/master
        echo "获取最新数据"
        git pull
        #设置目录权限
        chown -R www:www $gitPath
        echo "End"
        exit
else
        echo "该项目路径不存在"
        echo "End"
        exit
fi

五、将生成的POST添加至仓库推送