基于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

相关推荐
APItesterCris1 小时前
Python + 淘宝 API 开发实战:自动化采集商品详情与 SKU 数据清洗指南
大数据·运维·数据库·自动化
Dola_Zou1 小时前
在多系统环境中实现授权闭环,Tetra Pak 借助CodeMeter打造食品工业的安全自动化体系
安全·自动化·软件工程·软件加密
爱的叹息18 小时前
AI应用开发平台 和 通用自动化工作流工具 的详细对比,涵盖定义、核心功能、典型工具、适用场景及优缺点分析
运维·人工智能·自动化
电气外传21 小时前
S06-Kep的跨通道传输
程序人生·自动化
爱喝酸奶的桃酥1 天前
自动化备份全网服务器数据平台
服务器·自动化·github
亿牛云爬虫专家1 天前
浏览器自动化检测对抗:修改navigator.webdriver属性的底层实现
python·selenium·自动化·爬虫代理·amazon·代理ip·playwright
紫菜(Nori)1 天前
Jenkins 代理自动化-dotnet程序
运维·自动化·jenkins
GoMaxAi1 天前
金融行业 AI 报告自动化:Word+PPT 双引擎生成方案
人工智能·unity·ai作画·金融·自动化·aigc·word
that's boy2 天前
字节跳动开源 LangManus:不止是 Manus 平替,更是下一代 AI 自动化引擎
运维·人工智能·gpt·自动化·midjourney·gpt-4o·deepseek
struggle20252 天前
Trinity三位一体开源程序是可解释的 AI 分析工具和 3D 可视化
数据库·人工智能·学习·3d·开源·自动化