TAGS="bindata sqlite sqlite_unlock_notify" make build
启动 Gitea 主程序。这里先走完初始化步骤,会生成一个配置文件,位于当前目录下的
./custom/conf/app.ini
编辑上述配置文件,打开 Actions 功能。
[actions]ENABLED = true
重新启动程序:./gitea web
2.启动 Runner
首先编译act_runner程序
git clone https://gitea.com/gitea/act_runner.git
cd act_runner
make build
然后将 Runner 注册到 Gitea 服务器。
方法一:使用交互命令配置
$ ./act_runner register
INFO Registering runner, arch=amd64, os=linux, version=0.1.5.
WARN Runner in user-mode.
INFO Enter the Gitea instance URL (for example, https://gitea.com/): [输入服务器地址]
INFO Enter the runner token: [输入 Runner 令牌]
INFO Enter the runner name (ifset empty, use hostname:ubuntu ): [输入 Runner 名称]
INFO Enter the runner labels, leave blank to use the default labels (comma-separated, for example, ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster): [输入 Runner 标签]
...
DEBU Successfully pinged the Gitea instance server
INFO Runner registered successfully.
以下是一个示例,将它保存到.gitea/workflows/build.yaml时会触发 CI 工作:
name: Gitea Actions Demo
run-name: ${{ github.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo"🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo"🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo"🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo"💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo"🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls${{ github.workspace }}
- run: echo"🍏 This job's status is ${{ job.status }}."
体验 Gitea Actions
学习 GitHub Actions
Gitea 的 DevOps 生态
得益于广大开源社区的支持,目前 Gitea 可以良好适配以下 DevOps 工具。
打造 Gitea Actions
不可否认 GitHub Actions 打造了一套很棒的工作环境,它的设计理念使仓库与 CI 工具之间有了更加紧密的集成,实现了代码即配置,同时平台用户为整套系统提供了丰富的应用扩展,相比传统模式来说,易用性上更胜一筹。如果能将它的优点移植到 Gitea 将是件很棒的事情。
好消息是,经过两年的调研与讨论,我们终于将 Gitea 内置CI/CD系统的开发任务提上了日程。(#13539)
开发进展
Gitea Actions 实现了一个内置的 CI/CD 系统框架,兼容 GitHub Actions 的 YAML 工作流编排格式,兼容 GitHub Marketplace 中大部分现有的 Actions 插件。
系统由三部分组成:
运行截图
1.系统管理员可以访问 Runners 管理界面,创建、编辑和删除 Runner。
2.通过仓库顶部的导航打开 Actions,查看 CI 构建信息。
3.点击某个 CI 构建结果,查看日志。
尝鲜体验
准备环境
搭建
1.编译运行 Gitea
下载带有 Actions 模块的 Gitea 源代码:
编译方法可以参考从源代码安装。这里我们需要准备开发环境 Node.js LTS (
nvm instal --lts
) 和 Golang。以下是推荐的打包方法(带有SQLite,方便本地测试)
启动 Gitea 主程序。这里先走完初始化步骤,会生成一个配置文件,位于当前目录下的
编辑上述配置文件,打开 Actions 功能。
重新启动程序:
./gitea web
2.启动 Runner
首先编译
act_runner
程序然后将 Runner 注册到 Gitea 服务器。
--no-interactive
--instance
填写服务器地址--token
填写管理员从服务器获取的 Actions 令牌(/admin/runners
)启动程序
3.为仓库启用 Actions 功能
您可以新建一个仓库并手动开启仓库设置中的 Actions 功能。
刷新页面后,我们可以发现仓库的顶部功能导航栏中多了一个 Actions 功能,点击 Actions 进入可以看到目前为空的 All Workflows 任务列表。
4.上传 Workflows 配置到仓库目录
.gitea/workflows/build.yaml
。由于 Gitea Actions 兼容 GitHub Actions,因此您可以从 GitHub 文档中复制示例。开始学习使用 Gitea Actions 吧!以下是一个示例,将它保存到
.gitea/workflows/build.yaml
时会触发 CI 工作:与此同时,我们再次导航到 Actions 功能面板,可以看到刚刚创建 Workflow 已经执行并且记录下了运行日志。
5.检查 CI 执行过程产生的日志。不难看出 Gitea Runner 拉取了 Docker 镜像作为 CI 构建过程所需的基础环境。
6.从 GitHub 文档中了解更多 Actions 用法,同时可以为我们提出改进意见!