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

相关推荐
施努卡机器视觉19 小时前
SNK施努卡车门自动化安装
运维·自动化
2401_77CN19 小时前
汇川Easy系列PLC封装一阶低通滤波器FC【双线性变换】(定时中断应用,固定步长求解)
笔记·自动化
青靴20 小时前
轻量级 CI/CD:Git Hooks 自动部署 Node.js 应用(CICD-demo)
git·ci/cd·node.js
一晌小贪欢21 小时前
【Python办公】用 Selenium 自动化网页批量录入
开发语言·python·selenium·自动化·python3·python学习·网页自动化
垂金烟柳1 天前
MongoDB GridFS 历史数据自动化清理实践
数据库·mongodb·自动化
青靴1 天前
轻量级 CI/CD 实战(四):本地开发钉钉告警 → 自动部署云服务器 Kafka 消费者容器
ci/cd·docker·钉钉
奔跑吧邓邓子1 天前
Jenkins自动化持续集成:从入门到实战
ci/cd·自动化·实战·jenkins·自动化持续集成
ALex_zry2 天前
MySQL运维管理技术手册:从监控到自动化实战
运维·mysql·自动化
守城小轩2 天前
基于Chrome140的X账号自动化(关键词浏览)——脚本撰写(二)
自动化·chrome devtools·rpa·浏览器自动化
snpgroupcn2 天前
如何在SAP中实现数据验证自动化?5天缩短验证周期,提升转型效率的3大关键策略
运维·人工智能·自动化