更新README
This commit is contained in:
parent
e551d7a18a
commit
c5a5e45c97
28
README.md
28
README.md
@ -4,13 +4,16 @@
|
||||
## 🔨 步骤
|
||||
### 1 安装
|
||||
在需要实现自动部署的机器上安装本项目。
|
||||
#### 1.1 下载
|
||||
#### 1.1 构建
|
||||
```shell
|
||||
# clone至本地
|
||||
git clone https://git.lolli.tech/lollipopkit/gogs-webhook
|
||||
# 构建
|
||||
go build
|
||||
```
|
||||
#### 1.2 开机自启
|
||||
在`~/.config/systemd/user/`目录下创建一个文件,命名为`gogs-webhook-deploy.service`,内容如下:
|
||||
```shell
|
||||
```s
|
||||
[Unit]
|
||||
Description=Gogs Webhook Deploy Service
|
||||
After=network.target
|
||||
@ -19,31 +22,32 @@ After=network.target
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
ExecStart={ABSOLUTE_PATH_TO_GOGS_WEBHOOK}
|
||||
WorkingDirectory={ABSOLUTE_PATH_TO_GOGS_WEBHOOK}
|
||||
ExecStart={ABSOLUTE_PATH_TO_GOGS_WEBHOOK_DIR}/gogs-webhook -a ":3001"
|
||||
WorkingDirectory={ABSOLUTE_PATH_TO_GOGS_WEBHOOK_DIR}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
请将`{ABSOLUTE_PATH_TO_GOGS_WEBHOOK}`替换为下载的本项目的绝对路径。
|
||||
`{ABSOLUTE_PATH_TO_GOGS_WEBHOOK_DIR}`为Clone的目录绝对路径
|
||||
|
||||
然后执行:
|
||||
```shell
|
||||
systemctl --user enable --now gogs-webhook-deploy.service
|
||||
```
|
||||
如果需要在机器启动后(用户未登录时)自动启动,请执行:
|
||||
如果需要在系统启动但用户未登录时就自动启动,请执行:
|
||||
```shell
|
||||
sudo loginctl enable-linger {USER}
|
||||
```
|
||||
`{USER}`为你在系统中的用户名
|
||||
|
||||
### 2 配置
|
||||
#### 2.1 Git项目
|
||||
#### 2.1 Git
|
||||
在Gogs中创建一个Git项目,并为其设置Webhook。
|
||||
|
||||
进入你的项目`https://git.lolli.tech/USER/PROJECT/settings/hooks/gogs/new`,填写相关信息。
|
||||
#### 2.2 自动部署的项目
|
||||
在项目里添加自动部署脚本(默认是`deploy.py`,[示例](https://git.lolli.tech/lollipopkit/gogs-webhook/src/master/example/deploy.py))。
|
||||
#### 2.3 Gogs-Webhook-Deploy配置
|
||||
#### 2.2 项目
|
||||
在需要自动部署的项目里添加自动部署脚本(默认是`deploy.py`,[示例](https://git.lolli.tech/lollipopkit/gogs-webhook/src/master/example/deploy.py))。
|
||||
#### 2.3 Gogs-Webhook-Deploy
|
||||
在clone本项目的目录内添加`config.json`
|
||||
```json
|
||||
[
|
||||
@ -62,7 +66,7 @@ sudo loginctl enable-linger {USER}
|
||||
更改本配置后,不需要重启服务,会自动加载最新配置。
|
||||
|
||||
### 3 尝试自动部署
|
||||
⚠️**注意**,请仔细阅读下一节`要求`,然后尝试自动部署。
|
||||
⚠️ **注意**,请仔细阅读下一节[要求](https://git.lolli.tech/lollipopkit/gogs-webhook#-%E8%A6%81%E6%B1%82),然后尝试自动部署。
|
||||
在需要部署的项目内,新建commit,commit message内需要包含刚在`config.json`内配置的`signal`(默认`{D}`),然后push。
|
||||
|
||||
如果未能成功,请查看clone的本项目内的`.log`文件夹内的日志。
|
||||
@ -75,7 +79,7 @@ sudo loginctl enable-linger {USER}
|
||||
- 如果要部署非默认分支,需要手动切换到对应的git分支
|
||||
|
||||
## 🔍 CLI
|
||||
```sh
|
||||
```shell
|
||||
Usage of gogs-webhook:
|
||||
-a string
|
||||
Address to listen on (default ":3001")
|
||||
|
Loading…
x
Reference in New Issue
Block a user