基于gitea+act_runner 搭建CI/CD自动化部署

基于gitea+act_runner 搭建CI/CD自动化部署

Gitea 的搭建可以参考另一片文章
在Centos 上搭建代码管理平台Gitea

  1. 设置Gitea

    • 要求Gitea版本必须大于1.19.0

    • 小于1.21.0版本需要手动开启actions功能,在app.ini配置文件中

      ini 复制代码
      [actions]
      ENABLED=true
  2. 登录gitea 官网下载与gitea版本对应的act_runner

    https://dl.gitea.com/act_runner/

  3. 注册Runner 实例

    sh 复制代码
    ./act_runner register --no-interactive --instance <instance> --token <token>

    需要两个必需的参数:instancetoken

    instance是您的Gitea实例的地址,如http://192.168.8.8:3000https://gitea.com

    token用于身份验证和标识,例如P2U1U0oB4XaRCi8azcngmPCLbRpUGapalhmddh23. 它只能使用一次,并且不能用于注册多个Runner。 您可以从以下位置获取不同级别的token,从而创建出相应级别的`runner

    • 实例级别:管理员设置页面,例如 <your_gitea.com>/admin/actions/runners
    • 组织级别:组织设置页面,例如 <your_gitea.com>/<org>/settings/actions/runners
    • 存储库级别:存储库设置页面,例如 <your_gitea.com>/<owner>/<repo>/settings/actions/runners

    token 的具体位置在管理后台=>actions=>Runners 创建Runner下生成token

    出现如下内容代表注册成功

  4. 启动Runner

    sh 复制代码
    ./act_runner daemon
  5. 在对应的存储库的设置, 高级设置中启用Actions

    yaml 复制代码
    name: Gitea Actions Demo
    run-name: ${{ gitea.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 ${{ gitea.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 ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
          - name: Check out repository code
            uses: actions/checkout@v4
          - run: echo "💡 The ${{ gitea.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 ${{ gitea.workspace }}
          - run: echo "🍏 This job's status is ${{ job.status }}."

    上面的就是一个简单的demo, 将此内容存放到存储库的.gitea/workflows/目录中, 文件后缀为.yaml. 例如.gitea/workflows/demo.yaml

相关推荐
程序员的世界你不懂9 天前
Appium+python自动化(三十)yaml配置数据隔离
运维·appium·自动化
东窗西篱梦10 天前
LNMP一键自动化部署
运维·自动化
Deepoch10 天前
Deepoc大模型重构核工业智能基座:混合增强架构与安全增强决策技术
人工智能·科技·学习·自动化·创业创新
忘记安全带10 天前
AWS EC2使用SSM会话管理器连接
服务器·网络·自动化·云计算·aws
你的秋裤穿反了10 天前
网络/信号/电位跟踪
自动化
小猴崽10 天前
腾讯云事件总线:构建毫秒级响应的下一代事件驱动架构
架构·自动化·腾讯云
mit6.82410 天前
[project-based-learning] 开源贡献指南 | 自动化链接验证 | Issue模板规范
开源·自动化·issue
疯狂的维修10 天前
七层网络模型与电脑通信比喻
自动化
饺子大魔王的男人10 天前
Windows环境Browser-Use平台部署与AI自动化远程访问实现过程
人工智能·windows·自动化
云云32110 天前
亚矩云手机赋能Vinted矩阵运营:破解二手电商多账号与本地化困局
网络·人工智能·智能手机·矩阵·自动化