About workflow templates
Workflow templates are templates that help you to create your own GitHub Actions workflows for a repository. They offer an alternative to starting from a blank workflow file and are useful because some of the work will already have been done for you.
GitHub offers workflow templates for a variety of languages and tooling. When you set up workflows in your repository, GitHub analyzes the code in your repository and recommends workflows based on the language and framework in your repository. For example, if you use Node.js, GitHub will suggest a workflow template file that installs your Node.js packages and runs your tests. You can search and filter to find relevant workflow templates.
GitHub 为以下高级类别提供现成的工作流模板:
- 部署 (CD) 。 有关详细信息,请参阅“关于使用 GitHub Actions 进行持续部署”。
- 安全性。 有关详细信息,请参阅“配置代码扫描的高级设置”。
- 持续集成 (CI) 。 有关详细信息,请参阅“关于使用 GitHub Actions 进行持续集成”。
- 自动化. 自动化工作流模板提供了自动化工作流的解决方案,例如,对拉取请求分类并根据拉取请求中修改的路径对拉取请求应用标签,或问候首次参与存储库的用户。
使用这些工作流作为构建自定义工作流的起点或按原样使用它们。 可以在 actions/starter-workflows 存储库中浏览工作流模板的完整列表。
You can also create your own workflow template to share with your organization. These workflow templates will appear alongside the GitHub-provided workflow templates. Anyone with write access to the organization's .github
repository can set up a workflow template. For more information, see Creating workflow templates for your organization.
Choosing and using a workflow template
-
在 GitHub 上,导航到存储库的主页面。
-
在存储库名称下,单击 “操作”。
-
如果存储库中已有工作流,请单击“新建工作流”。
-
The "Choose a workflow" page shows a selection of recommended workflow templates. Find the workflow template that you want to use, then click Configure. To help you find the workflow template that you want, you can search for keywords or filter by category.
-
If the workflow template contains comments detailing additional setup steps, follow these steps.
There are guides to accompany many of the workflow templates for building and testing projects. For more information, see Building and testing.
-
Some workflow templates use secrets. For example,
${{ secrets.npm_token }}
. If the workflow template uses a secret, store the value described in the secret name as a secret in your repository. For more information, see Using secrets in GitHub Actions. -
Optionally, make additional changes. For example, you might want to change the value of
on
to change when the workflow runs. -
Click Start commit.
-
Write a commit message and decide whether to commit directly to the default branch or to open a pull request.