-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
这里记录一下Github Action的从入门到还没放弃的历程。 :)
1. Hello World
我们可以通过repo的action的指引,快速的完成Github action的测试:

点击detail后,我们便可以完成Hello world的测试:

可以看到,整个过程非常简单,只需要提交一个位于.github/hello-wrold.yml的文件:
name: CI
# 在push的时候触发这个workflow
on: [push]
# workflow的job内容
jobs:
build:
# 跑job的系统
runs-on: ubuntu-latest
# 定义需要跑的脚本
steps:
# 使用checkout action
- uses: actions/checkout@v2
# Hello World
- name: Run a one-line script
run: echo Hello, world!
# 打印多行
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.我们可以点击detail进入Workflow的结果页面
2. 初识Action
官方的文档介绍的非常详细了,这里推荐一些文章,官方在action的文档主页中推荐了3个文章,这里简单介绍下:
-
About GitHub Actions
这篇文章主要从从使用者的角度对action进行了简单的介绍,通过这篇文章可以了解到使用Github action的一些注意事项(例如使用限制、通知机制等都在这里有提及)。 -
Configuring a workflow
这篇文章可以认为是对workflow的一个详解,并且对workflow中的关键概念进行了解释,把这篇文章读透,基本上Github Action的基础功能就了然于胸了。 -
About actions
这篇文章可以认为是写给action的开发者的一个入门文档,在你需要写一个action之前,建议通读这篇文章。
3. 高级功能
在这节会陆续更新下,我使用到的有用的功能:
- 缓存
https://github.com/actions/cache cache插件提供了缓存上一次指定目录的文件的功能,例如缓存依赖包。 - 接入自定义机器
https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners 当你需要使用自定义机器时(例如对接特殊硬件等需求),可以使用self hosted runners功能。 - 使用加密功能
https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets 当你需要使用一些加密的字符或者秘钥之类时,可以配合Github的secrets进行使用。
