2022
我们一起努力

Github原生CI/CD,初尝Github Actions

Github 目前已经推出了自己的 CICD 服务 —— Github Actions,而且比微软的 Azure DevOps Pipelines 对开发者来说更友好,使用起来更好用。

Github原生CI/CD,初尝Github ActionsGithub原生CI/CD,初尝Github Actions

Github Actions 核心概念

总体看下来感觉是从 Azure Pipelines 迁移过来的东西,有许多概念和 Azure Pipelines 是类似的,如果你之前用过 azure pipelines,应该很容易上手

‎ Runner 用来跑 cicd build 的服务器‎ ‎ Github Hosted Runner Github 官方提供的 Runner‎ ‎ Self-Hosted Runner 用自己的服务器作为 Runner‎ ‎ Workflow 定义 CI/CD 的流程,需要执行哪些操作,需要做什么‎ ‎ Workflow 定义 workflow 的配置文件,通常放在项目根目录下的 .github/workflows 文件夹下‎ ‎ Workflow Run 每一次 CI/CD build‎ ‎ Event 触发 ci/cd build 的事件,如 push/issue/pr‎ ‎ Job 由一系列 Step 组成,Job 可以并行执行也可以串行执行,每一个 Job 都是一个新的环境‎ ‎ Step 对应 Job 执行的每一个步骤‎ ‎ Action 对应 Step 里执行的可复用的操作‎

Github Actions 配置示例

来看一个 Github Actions 的 dotnet 配置:

name: dotnetcore # workflow name

on: [push] # event trigger,什么事件触发 build

jobs:
 build:
   runs-on: ubuntu-latest # 指定 runner,使用 Github 提供的 runner

   steps:
   - uses: actions/checkout@v1 # checkout
   - name: Setup .NET Core # 设置 dotnet core 环境
     uses: actions/setup-dotnet@v1
     with:
       dotnet-version: 3.0.100
   - name: dotnet info # 输出 dotnet -info,查看 dotnet 版本信息
     run: dotnet --info
   - name: build
     run: bash build.sh # 在 bash 中运行 build 脚本

徽章

Sample:

[![Github Build Status](https://github.com/WeihanLi/WeihanLi.Common/workflows/dotnetcore/badge.svg?branch=dev)](https://github.com/WeihanLi/WeihanLi.Common/actions?query=workflow%3Adotnetcore+branch%3Adev)

Github Build Status


https://github.com///workflows//badge.svg

https://github.com///workflows//badge.svg?branch=

本文来源:www.lxlinux.net/8719.html,若引用不当,请联系修改。

赞(0)
文章名称:《Github原生CI/CD,初尝Github Actions》
文章链接:https://www.fzvps.com/229785.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。

评论 抢沙发

评论前必须登录!