Gitea Actions sắp tới cam kết tạo ra một giao thức chuẩn cho các công cụ CI/CD. Hệ thống CI của bên thứ ba có thể được tích hợp với nền tảng Gitea dựa trên giao thức hành động để cung cấp giải pháp quản lý một cửa. Gitea Actions thực hiện bước đầu tiên hướng tới mục tiêu này.
Xem lại các hành động của GitHub
GitHub Actions là nền tảng tích hợp liên tục và phân phối liên tục (CI/CD) có thể được sử dụng để tự động hóa các tác vụ, thử nghiệm và triển khai. Người dùng có thể tạo quy trình công việc để xây dựng và kiểm tra mọi yêu cầu kéo cho kho lưu trữ hoặc triển khai các yêu cầu kéo đã hợp nhất vào sản xuất.
GitHub Actions không chỉ là DevOps, cho phép người dùng chạy quy trình làm việc khi các sự kiện khác xảy ra trong kho lưu trữ. Ví dụ: bạn có thể chạy quy trình làm việc để khi ai đó tạo câu hỏi mới, thẻ thích hợp sẽ tự động được thêm vào.
GitHub cung cấp các máy ảo Linux, Windows và macOS để chạy quy trình công việc hoặc lưu trữ các trình chạy trong trung tâm dữ liệu hoặc cơ sở hạ tầng đám mây của riêng mình.
Hệ sinh thái DevOps của Gitea
Nhờ sự hỗ trợ của cộng đồng mã nguồn mở rộng lớn, Gitea hiện có thể thích ứng tốt với các công cụ DevOps sau.
- Agola
- Ứng dụngVeyor
- Tích hợp AWS Cloud (webhook-to-s3)
- buildbot-gitea
- buildkite-kết nối
- Sảnh chờ
- Dex
- Máy bay không người lái
- Ghorg
- ngốc nghếch
- Jenkins
- CI Jianmu
- Tuyến tàu điện ngầm
- Giám sát mixin
- mvoCI
- Cải tạo
- Trà Runner
- Chim gõ kiến
经过长期的社区互动,我们获得了大量第三方CI系统的集成方案。但我们始终发现,独立搭建并运维一整套CI系统只是一小部分极客的专长,对于更广泛的用户而言这并不是个简单的工作,于是我们开始尝试为此努力,让工具更好地为人服务.
打造 Gitea Actions
不可否认 GitHub Actions 打造了一套很棒的工作环境,它的设计理念使仓库与 CI 工具之间有了更加紧密的集成,实现了代码即配置,同时平台用户为整套系统提供了丰富的应用扩展,相比传统模式来说,易用性上更胜一筹。如果能将它的优点移植到 Gitea 将是件很棒的事情.
好消息是,经过两年的调研与讨论,我们终于将 Gitea 内置CI/CD系统的开发任务提上了日程。( #13539 ) 。
开发进展
https://github.com/go-gitea/gitea/issues/13539 。
Gitea Actions 实现了一个内置的 CI/CD 系统框架,兼容 GitHub Actions 的 YAML 工作流编排格式,兼容 GitHub Marketplace 中大部分现有的 Actions 插件.
系统由三部分组成:
- Gitea Actions 协议的 定义 和 Golang实现
- Actions Runner: 基于 nektos/act 实现的任务子系统
- 在 Gitea 主程序上实现 Runner 任务管理和调度模块
运行截图
1.系统管理员可以访问 Runners 管理界面,创建、编辑和删除 Runner.
2.通过仓库顶部的导航打开 Actions,查看 CI 构建信息.
3.点击某个 CI 构建结果,查看日志.
尝鲜体验
⚠ 实验性功能,请勿用于生产环境 。
准备环境
- 内存:至少 4GB,用于编译 Gitea
- Docker:可执行 docker 命令,用于拉取和运行容器
搭建
1.编译运行 Gitea 。
下载带有 Actions 模块的 Gitea 源代码:
# 目前可以从 @wolfogre 的开发分支克隆带有 Actions 模块的源代码到本地编译。 git clone https://github.com/wolfogre/gitea.git --branch=feature/bots cd gitea
编译方法可以参考 从源代码安装 。这里我们需要准备开发环境 Node.js LTS ( nvm instal --lts ) 和 Golang.
以下是推荐的打包方法(带有SQLite,方便本地测试) 。
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 (if set 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.
- 方法二:非交互式命令
-
--no-interactive
-
--instance
填写服务器地址
-
--token
填写管理员从服务器获取的 Actions 令牌( /admin/runners
)
./act_runner register --instance http:// --token --no-interactive
启动程序 。
./act_runner daemon
3.为仓库启用 Actions 功能 。
您可以新建一个仓库并手动开启仓库设置中的 Actions 功能.
刷新页面后,我们可以发现仓库的顶部功能导航栏中多了一个 Actions 功能,点击 Actions 进入可以看到目前为空的 All Workflows 任务列表.
4.上传 Workflows 配置到仓库目录 .gitea/workflows/build.yaml 。由于 Gitea Actions 兼容 GitHub Actions,因此您可以从 GitHub 文档中复制示例。开始学习使用 Gitea Actions 吧! 。
阅读文档 https://docs.github.com/en/actions/quickstart
以下是一个示例,将它保存到 .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 }}."
与此同时,我们再次导航到 Actions 功能面板,可以看到刚刚创建 Workflow 已经执行并且记录下了运行日志.
5.检查 CI 执行过程产生的日志。不难看出 Gitea Runner 拉取了 Docker 镜像作为 CI 构建过程所需的基础环境.
6.从 GitHub 文档中了解更多 Actions 用法,同时可以为我们提出改进意见.
Implement actions https://github.com/go-gitea/gitea/pull/21937 GitHub Actions https://docs.github.com/zh/actions/using-workflows
最后此篇关于体验GiteaActions的文章就讲到这里了,如果你想了解更多关于体验GiteaActions的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
Tôi là một lập trình viên xuất sắc, rất giỏi!