创建一个工作流程
-
从 GitHub 上的仓库,在
.github/workflows目录中创建一个名为github-actions-demo.yml的新文件。 -
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 }}."
- 滚动到页面底部,然后选择 Create a new branch for this commit and start a pull request(为此提交创建一个新分支并开始拉取请求)。 然后,若要创建拉取请求,请单击 Propose new file(提议新文件)。
向仓库的分支提交工作流程文件会触发 push 事件并运行工作流程。
查看工作流程结果
-
在 GitHub 上,导航到仓库的主页面。
-
在仓库名称下,单击 Actions(操作)。
-
在左侧边栏中,单击您想要查看的工作流程。
-
从工作流程运行列表中,单击要查看的运行的名称。
-
在 Jobs(作业)下,单击 Explore-GitHub-Actions 作业。
-
日志显示每个步骤的处理方式。 展开任何步骤以查看其细节。
例如,您可以在仓库中看到文件列表: