Github native CI / CD, begun Github Actions

Github native CI / CD, begun Github Actions

Intro

Github has now launched its own CICD service - Github Actions, and more friendly to developers than Microsoft Azure DevOps Pipelines, using them easier to use.

Github Actions core concepts

The overall feeling is that things look down from the Azure Pipelines migrate over, there are many concepts and Azure Pipelines are similar, if you previously used the azure pipelines, should be very easy to use

  • Runner to run cicd build the server
    • Github Hosted Runner Github official of Runner
    • Self-Hosted Runner with their own server as Runner
  • Process Workflow definition of CI / CD and what you need to do, what to do
  • Workflow-defined workflow configuration file, usually placed in the root directory of the project .github/workflowsfolder
  • Workflow Run every CI / CD build
  • Event Event triggers ci / cd build, such as the push / issue / pr
  • Job consists of a series Step composition, Job can be executed in parallel serial execution, each Job is a new environment
  • Each step corresponds to Step Job execution
  • Action corresponding to the operation of the reusable performed in Step

Configuration Example Github Actions

Look at a Github Actions of dotnet configuration:

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 脚本

Github example: https://github.com/WeihanLi/WeihanLi.Common/blob/dev/.github/workflows/dotnetcore.yml

More

badge:

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/<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_NAME>/badge.svg

https://github.com/<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_NAME>/badge.svg?branch=<branch-name>

Summary

Overall, it can also be used, but the feeling is not as good as travis-ci and azure pipelines mature, say ci commonly supported by both commit message contains [skip ci] does not trigger the build, the current Github Action is not supported, but after all, is new to the product, I believe the future will be better and better clatter, want to try the little friends can practice what

Reference

Guess you like

Origin www.cnblogs.com/weihanli/p/11980499.html