什麽是Github Actions呢?这是Github平台
在2019年上架的CI功能,使用Github Actions可以让你将以往给Jenkins的工作交给Github来完成,并除了原先Github的版本控管外整合Build、Test、Deploy。这个过程我们称作是github workflows。
Github Actions相关的中文文件
影片介绍:
什麽是github workflows呢? 打一个上方影片的比方,假如我们现在正在写一个JAVA套件,有多个contributors给予贡献,也有多个Users。当user发现bug後会发布issue,此时就要思考流程是:
当一个contributor修好了bug,并且pull requests後,要思考流程是:
发布新的版本时要做的流程:
这几个过程merge code -> Test -> Build -> Deployment
可以称做一个workflows,当有越来越多的contributors、issues、pull requests,整个workflows就会越混乱,因此,自动化is the best。
什麽驱动workflows呢?我们称作Github event,例如: Pull Requests created、Issue create、Contributor join、Pull requests merged...等。
所以基本上就是监控event去驱动workflows该做什麽事。
点击 Acitons,里面会包含很多根据专案推荐的Workflows流程(左下图),还有workflow范例(右图)如新加入的contributor say Greetings之类的。
但是以上先都不管,我们先来简单的看一下简单的范例,在你的专案下建立.github/workflows/github-actions-demo.yml
。
name: GitHub Actions Demo
on:
push:
branches:
- "master"
pull_request:
branches: ["master"]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "? The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "? This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "? The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v2
with:
fetch-depth: 0
- run: echo "? The ${{ github.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 ${{ github.workspace }}
- run: echo "? This job's status is ${{ job.status }}."
简单讲解一下,可以参考文件
name
: 是workflows的名称on
: 是驱动workflow的事件,详细参考,你可以指定哪个branch才会驱动。jobs
: 是一连串的steps组成,你可以拥有1~多个job。steps
: 可以运行命令(run)、执行actions(uses)、设定参数(with)uses
: 使用github上其他人写好可reuse的action举个例子,上面的actions/checkout@v2
,你可以在一个名为actions/checkout的repository内找到。进入该repository,打开action.yml
档,可以看到具体内容,@後面是版本。
run
: 就是执行commandwith
: 设定use actions的变数接着我们把它push上github,点击repository的actions。可以看到运行的workflow
点击,打开後你就可以看到CI的输出。
此外,你在README加上
![example workflow](https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/<WORKFLOW_FILE>/badge.svg)
填入使用者(OWNER)、专案名称(PEPOSITORY)、你的worflow档案名称(WORKFLOW_FILE),即可出现一个验证符号:
我们明天来实作将Express自动push上Azure云端并执行的CI整合。
<<: [C 语言笔记--Day17] 让一个绝对不会 return 的 function 进行一点优化
引言:Terraform 是个好东西。 课程内容与代码会放在 Github 上: https://g...
来部落格看图文并茂文章 补觉鸣诗 时间回到我入行第二年 这时才算是正式的系统工程师并开机接触机房 最...
URL : https://tryhackme.com/room/archangel IP : 1...
不知不觉过了三十天,在这三十天中,我们学习了 Coroutine 的每一个面向,我们知道 Corou...
Day1 简介 前言 今天先简单介绍为什麽要写这个,其实训练一个模型不难,许多相关的教学都讲得相当清...