Gitea Actions 基本上和 Github Actions 一样的语法,兼容 Github 的 actions 软件包,经过我的测试有一些 actions 的包是不能运行的。
Gitea 行动的目的是在 Gitea 和现有的 CI/CD 系统之间实现更紧密的集成。另一个目标是为独立运行器提供统一的管理界面,以减少支持多个系统的管理开销(如果需要)。独立运行器工作流旨在与 GitHub Actions 兼容,可用于在 Gitea 上构建、测试、打包、发布或部署任何代码项目。
Gitea Actions 不仅仅是 DevOps,还允许您在存储库中发生其他事件时运行工作流。例如,您可以运行工作流,以便在有人在您的存储库中创建新问题时自动添加相应的标签。
安装
使用 Gitea 1.19.0 及以上版本,未安装的请参考 Gitea Docs
这里我使用宝塔面板和腾讯云的服务器,提前在面板安装好 Docker 环境。
- Gitea 开启 actions 选项
actions 的配置默认是禁用的,需要修改文件进行开启,修改gitea/config/app.ini 配置文件,修改完成之后建议重启一下。
- 查看 Gitea Runner token
管理后台 - Actions -Runners - 创建 Runner - 这里有 token 要记下来后面会用到。

- 安装 act runner
使用 docker compose 启动,在 gitea 的目录下新建一个cet runner文件夹添加docker-compose.yml
1version: "3"
2services:
3 act_runner:
4 image: gitea/act_runner:latest
5 restart: always
6 environment:
7 - GITEA_INSTANCE_URL=https://192.168.0.1:3000/
8 - GITEA_RUNNER_REGISTRATION_TOKEN=5NwZolPXGrRZ
9 - GITEA_RUNNER_NAME=docker_runner
10 volumes:
11 - /var/run/docker.sock:/var/run/docker.sock
12 - ./act_data:/data
13 - ./ct_cache:/root/.cache
GITEA_INSTANCE_URL是 gitea 的地址GITEA_RUNNER_REGISTRATION_TOKEN填写你获取的 token
- 查看是否添加成功
在 runner 管理面板即可看见新加入的 runner 的状态。

测试
- 创建仓库
创建一个demo的测试仓库,让我们来尝鲜一下吧。

- 添加工作流文件
以下为官方的一个实例,将它保存至 .gitea/workflows/build.yaml 会触发 CI 工作。,yaml 语法可参考 Github Actions Docs
1name: Gitea Actions Demo
2run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
3on: [push]
4jobs:
5 Explore-Gitea-Actions:
6 runs-on: ubuntu-latest
7 steps:
8 - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
9 - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
10 - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
11 - name: Check out repository code
12 uses: actions/checkout@v3
13 - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
14 - run: echo "🖥️ The workflow is now ready to test your code on the runner."
15 - name: List files in the repository
16 run: |
17 ls ${{ gitea.workspace }}
18 - run: echo "🍏 This job's status is ${{ gitea.status }}."
- 查看执行结果

来自以下文献: