Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Action入门指南 #83

Open
Yikun opened this issue Feb 28, 2020 · 0 comments
Open

Github Action入门指南 #83

Yikun opened this issue Feb 28, 2020 · 0 comments

Comments

@Yikun
Copy link
Owner

Yikun commented Feb 28, 2020

这里记录一下Github Action的从入门到还没放弃的历程。 :)

1. Hello World

我们可以通过repo的action的指引,快速的完成Github action的测试:
image
点击detail后,我们便可以完成Hello world的测试:
image

可以看到,整个过程非常简单,只需要提交一个位于.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的结果页面

image

2. 初识Action

官方的文档介绍的非常详细了,这里推荐一些文章,官方在action的文档主页中推荐了3个文章,这里简单介绍下:

  • About GitHub Actions
    这篇文章主要从从使用者的角度对action进行了简单的介绍,通过这篇文章可以了解到使用Github action的一些注意事项(例如使用限制、通知机制等都在这里有提及)。

  • Configuring a workflow
    这篇文章可以认为是对workflow的一个详解,并且对workflow中的关键概念进行了解释,把这篇文章读透,基本上Github Action的基础功能就了然于胸了。

  • About actions
    这篇文章可以认为是写给action的开发者的一个入门文档,在你需要写一个action之前,建议通读这篇文章。

3. 高级功能

在这节会陆续更新下,我使用到的有用的功能:

  1. 缓存
    https://github.com/actions/cache cache插件提供了缓存上一次指定目录的文件的功能,例如缓存依赖包。
  2. 接入自定义机器
    https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners 当你需要使用自定义机器时(例如对接特殊硬件等需求),可以使用self hosted runners功能。
  3. 使用加密功能
    https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets 当你需要使用一些加密的字符或者秘钥之类时,可以配合Github的secrets进行使用。
@Yikun Yikun added the Draft label Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant