注: GitHub 托管的运行器目前在 GitHub Enterprise Server 上不受支持。 您可以在 GitHub 公共路线图 上查看有关未来支持计划的更多信息。
概览
Starter workflows allow everyone in your organization who has permission to create workflows to do so more quickly and easily. When you create a new workflow, you can choose a starter workflow and some or all of the work of writing the workflow will be done for you. You can use starter workflows as a starting place to build your custom workflow or use them as-is. This not only saves time, it promotes consistency and best practice across your organization.
GitHub provides ready-to-use starter workflows for the following high level categories:
-
Deployment (CD). For more information, see "About continuous deployment."
-
Continuous Integration (CI). 更多信息请参阅“关于持续集成”。
-
Automation. Automation starter workflows offer solutions for automating workflows, such as triaging pull requests and applying a label based on the paths that are modified in the pull request, or greeting users who are first time contributors to the repository.
Creating a starter workflow
Starter workflows can be created by users with write access to the organization's .github
repository. These can then be used by organization members who have permission to create workflows.
This procedure demonstrates how to create a starter workflow and metadata file. The metadata file describes how the starter workflows will be presented to users when they are creating a new workflow.
-
如果组织中没有名为
.github
的公共仓库,请新建一个。 -
创建一个名为
workflow-templates
的目录。 -
在
workflow-templates
目录中创建新的工作流程文件。如果需要引用仓库的默认分支,可以使用
$default-branch
� 位符。 When a workflow is created the placeholder will be automatically replaced with the name of the repository's default branch.例如,下面这个名为
octo-organization-ci.yml
的文件展示了一个基本的工作流程。name: Octo Organization CI on: push: branches: [ $default-branch ] pull_request: branches: [ $default-branch ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Run a one-line script run: echo Hello from Octo Organization
-
在
workflow-templates
目录中创建元数据文件。 元数据文件必须与工作流程文件同名,但扩展名不是.yml
,而必须附�.properties.json
。 例如,下面这个名为octo-organization-ci.properties.json
的文件包含名为octo-organization-ci.yml
的工作流程文件的元数据:{ "name": "Octo Organization Workflow", "description": "Octo Organization CI starter workflow.", "iconName": "example-icon", "categories": [ "Go" ], "filePatterns": [ "package.json$", "^Dockerfile", ".*\\.md$" ] }
name
- Required. The name of the workflow. This is displayed in the list of available workflows.description
- Required. The description of the workflow. This is displayed in the list of available workflows.iconName
- Optional. Specifies an icon for the workflow that's displayed in the list of workflows. TheiconName
must be the name of an SVG file, without the file name extension, stored in theworkflow-templates
directory. For example, an SVG file namedexample-icon.svg
is referenced asexample-icon
.categories
- 可选。定义工作流程的语言类别。 When a user views the available starter workflows for a repository, the workflows that match the identified language for the project are featured more prominently. 有关可用语言类别的信息,请参阅https://github.com/github/linguist/blob/master/lib/linguist/languages.yml。filePatterns
- Optional. Allows the workflow to be used if the user's repository has a file in its root directory that matches a defined regular expression.
To add another starter workflow, add your files to the same workflow-templates
directory. 例如:
后续步骤
To continue learning about GitHub Actions, see "Using starter workflows."