Gitea Action初体验
本文最后更新于 697 天前, 如有失效请评论区留言.
Gitea Action 是一款基于 Action 协议且兼容 Github Action 的 Gitea 内置 CI 工具.
服务端部署
版本说明
需要 Gitea 1.19 及之后版本
Gitea Action 服务端部署比较简单, 可以参考在 k8s 上部署私有 Git 服务: Gitea
后台配置
需要使用管理员权限,访问管理后台, 如果没看到说明没开启 action 功能,需要在配置文件中开启
部署 runner
gitea action 是基于 github action 本地测试工具 act 衍生出来的。
目前支持两种模式, 但是都需要依赖 docker:
- 二进制方式
- 容器
综上, 方便起见二进制部署叭
下载二进制
https://dl.gitea.com/act_runner/main/act_runner-main-linux-amd64
注册 Runner
除了 URL 和 Token 需要自定义外,其他默认即可
./act_runner register
守护方式运行
[Unit]
Description=Act Runner
Documentation=https://k3s.io
Wants=network-online.target
[Install]
WantedBy=multi-user.target
[Service]
Type=exec
User=root
# EnvironmentFile=-/etc/systemd/system/k3s.service.env
WorkingDirectory=/root
KillMode=process
Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always
RestartSec=5s
ExecStart=/usr/bin/act-runner daemon
设置开机启动一梭子
systemctl enable gitea-act --now
启动完成后,看后台 runner 起来 Alive 就可以了
Action 初体验
- action 默认是未启用的,每个项目需要单独开启,
设置->仓库->Actions
- 兼容 github action, 基本不需要改动啥
name: checks
on:
- push
- pull_request
env:
GOPROXY: https://goproxy.io,direct
GOPATH: /go_path
GOCACHE: /go_cache
jobs:
lint:
name: check and test
runs-on: ubuntu-latest
steps:
- name: cache go path
id: cache-go-path
uses: https://github.com/actions/cache@v3
- uses: actions/setup-go@v3
with:
go-version: 1.20
- uses: actions/checkout@v3
- name: vet checks
run: make vet
简单说下, 推荐使用完整域名的 github action, gitea action 同步更新比较慢, 而且目前还不支持私有内网 action 或者带有加速域名如 https://ghproxy.com/https://github.com/actions/cache@v3
actions/checkout@v3 ---> https://gitea.com/actions/checkout@v3
https://github.com/actions/cache@v3 ---> https://github.com/actions/cache@v3
总结
如果 github action 玩的很 6, gitea action 很简单了哈,除了网络问题 😂
目前还是比较期待能支持 k8s 方式