GitHub Help

快速入门

# 作业流名称 name: GitHub Actions Demo # 作业流运行时名称 run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 # push 代码到分支时触发 on: [ push ] # 需要执行的作业集 jobs: # 作业名称 Explore-GitHub-Actions: # 作业运行环境 runs-on: ubuntu-latest # 作业运行步骤集 steps: # run 执行其后跟着的脚本, 这里是执行 `echo` 命令输出文本 # github.event_name -> push - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." # runner.os -> Linux - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" # github.ref -> refs/heads/<branch> # github.repository -> <user|org>/<repo> - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." # 步骤名称 - name: Check out repository code # https://github.com/actions/checkout uses: actions/checkout@v4 # github.repository -> <user|org>/<repo> - 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 # 使用 | 引导多行脚本 # github.workspace -> 默认工作目录的文件列表 run: | ls ${{ github.workspace }} # job.status -> success | failure | cancelled - run: echo "🍏 This job's status is ${{ job.status }}."
# 作业流名称 name: learn-github-actions # 作业流运行时名称 run-name: ${{ github.actor }} is learning GitHub Actions # 监听事件 on: [ push ] # 作业集 jobs: # 作业名称 check-bats-version: # 运行环境 runs-on: ubuntu-latest # 步骤集 steps: # 使用操作 https://github.com/actions/checkout - uses: actions/checkout@v4 # 使用操作 https://github.com/actions/setup-node - uses: actions/setup-node@v4 # 指定 actions/setup-node@v4 操作的环境变量 with: node-version: '20' # 执行脚本 - run: npm install -g bats # 执行脚本 - run: bats -v

查找 Actions

通常我们会在 GitHub Marketplace 上查找操作, 进而在我们的工作流中复用操作.

Last modified: 25 May 2024