GitHub Actions快速开始

421 阅读1分钟

欢迎访问个人博客: Torch-Fan

本文内容翻译自: docs.github.com/en/actions/…

1. 介绍

现在,你只需要一个GitHub仓库就能运行一个GitHub工作流。在这篇指南中,你将添加一个工作流来体验GitHub Actions的基本特性。

2. 创建第一个工作流

  1. 从你的GitHub仓库中,在.github/workflows中创建一个名为github-actions-demo.yml文件.
  2. 将下面的yaml文件内容复制到你的github-actions-demo.yml文件中:
name: GitHub Actions Demo
on: [push]
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
      - 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 }}."
  1. 在GitHub页面滑动滚轮,选择Create a new branch for this commit and start a pull request.随后创建一个pull request,点击Propose new file.

将工作流文件提交到仓库中会触发push事件,并因此执行该工作流。

3. 查看工作流结果

  1. 前往GitHub仓库主页
  2. 点击Actions 标签
  3. 进入Actions标签页后选择你想看到的工作流
  4. 进入工作流页面可以看到工作流的执行历史,选择你想看的某次执行历史
  5. 点进去可以看到每一步的执行结果

4. 更多工作流模板:

github.com/actions/sta…

本文由博客一文多发平台 OpenWrite 发布!