From 09b97b7e9572c76c79c0de0c69e81a35f5fb6383 Mon Sep 17 00:00:00 2001 From: liuxiaohua Date: Thu, 26 Jun 2025 16:29:13 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20[2025-06-26]=20=E6=B7=BB=E5=8A=A0Gi?= =?UTF-8?q?teaRunner=20Host=20=E6=A8=A1=E5=BC=8F=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=95=99=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20250626-GiteaRunner Host 模式配置教程.md | 221 ++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 教程/工具/20250626-GiteaRunner Host 模式配置教程.md diff --git a/教程/工具/20250626-GiteaRunner Host 模式配置教程.md b/教程/工具/20250626-GiteaRunner Host 模式配置教程.md new file mode 100644 index 0000000..93e50cc --- /dev/null +++ b/教程/工具/20250626-GiteaRunner Host 模式配置教程.md @@ -0,0 +1,221 @@ +# GiteaRunner Host 模式配置教程 + +## 下载二进制文件 + +- https://gitea.com/gitea/act_runner/releases +- 这边下载 `act_runner-0.2.12-linux-amd64` +- 配置 `act_runner` + +```shell +#- 重命名 +mv act_runner-0.2.12-linux-amd64 act_runner` +#- 授予执行权限 +chmod +x act_runner +``` + +## 配置 + +### 生成配置文件 + +```shell +./act_runner generate-config > config.yaml +``` + +### 修改配置文件 + +#### 修改下面的配置 + +```yaml +runner: + labels: + #- 添加 + - "linux-ubuntu-24.04:host" +host: + #- 不填写会提示文件找不到 + workdir_parent: /.cache/act +``` + +## 编写启动脚本 + +### 启动脚本内容 + +```shell +#!/bin/bash + +/${path}/act_runner register --no-interactive --instance ${gitea_url} --token ${runner_token} --name host-runner --labels host-runner +echo register + +/${path}/act_runner daemon --config /${path}/config.yaml +``` + +- ${path}: act_runner 所在目录 +- ${gitea_url}: gitea 访问地址 +- ${runner_token}: gitea 获取到的 runner token + +### 配置启动脚本执行权限 + +```shell +chmod +x register.sh +``` + +## 配置开机启动 + +```shell +vi /etc/systemd/system/gitea_runner.service + +#- 填入下面的内容 + +[Unit] +#- 服务名称,可自定义 +Description = gitlab runner host server +After = network.target syslog.target +Wants = network.target + +[Service] +Type = simple +#- 启动frps的命令,需修改为您的frps的安装路径 +ExecStart = /${path}/register.sh + +[Install] +WantedBy = multi-user.target +``` + +- ${path}: register.sh 所在文件目录 + +## 启动 + +```shell +#- 配置开机启动 +systemctl enable gitea_runner.service +#- 启动服务 +systemctl start gitea_runner.service +#- 重启 +systemctl restart gitea_runner.service +#- 停止 +systemctl stop gitea_runner.service +#- 查看状态 +systemctl status gitea_runner.service +``` + +## 安装 Git + +```shell +apt install git +``` + +## 配置Mark(markdown to confluence) + +### Mark 下载 + +- https://github.com/kovetskiy/mark/releases +- 这边使用的是 `mark_Linux_x86_64.tar.gz` 14.1.0 版本 + +### 解压到指定目录 + +```shell +tar -zxvf mark_Linux_x86_64.tar.gz + +chmod +x mark +``` + +## 配置 Gitea Workflow + +```yaml +name: Publish to Confluence +on: + push: + branches: [ master ] + #- paths: + #- - '**' + #- - '!.gitignore' + #- - '!README.md' + #- workflow_dispatch: # 允许手动触发工作流 + #- schedule: + #- # 每天晚六点十分执行一次 + #- - cron: '10 10 * * *' +env: + SEPARATOR: "," #- 定义多文件分割符 + START_PREFIX: "/g' $temp_path + # path 替换 + # sed -i -E 's/(.*\!\[.*\]\([ \t]*([a-zA-Z]\:)?(\.*(\/|\\))?([^:\r\n\t\!]*\.[a-zA-Z]+)[ \t]*\))([ ]*<\!\-\-[ \t]*width=[0-9]*[ \t]*\-\->)*/\1/g' $temp_path + # url 替换 + sed -i -E 's/(.*\!\[.*\]\([ \t]*(http(s)?:\/\/)([^:\r\n\t\!]*(\.[a-zA-Z]+)?)[ \t]*\))([ ]*<\!\-\-[ \t]*width=[0-9]*[ \t]*\-\->)*/\1/g' $temp_path + # 不支持的代码块替换 + sed -i -E 's/(.*)(```(dockerfile|json|toml|properties))(.*)/\1```shell\4/g' $temp_path + # 标题添加锚点 + sed -i -E 's/([#]+[ ]+)(.*)/\1\2 :anchor(\2):/g' $temp_path + sed -i -E "s@(\[.*\])(\(#)(.*)(\))@\1\2id-$(echo $temp_filename | tr -d '-')-\3\4@g" $temp_path + # 构建及发布 + /usr/local/programs/gitea/gitea_runner_host/mark --ci --log-level trace --include-path $(pwd) -p $MARK_PASS -b $MARK_URL -f $temp_path || exit 1; + else + echo "$temp_path not config metadata info, ignore file" + fi + done +``` + +- 配置Confluence相关信息 + - 在对应的仓库中配置密钥 + - ${{ secrets.ATLASSIAN_API_TOKEN }} + - ${{ secrets.ATLASSIAN_BASE_URL }} \ No newline at end of file