Creating workflow templates

Learn how you can create workflow templates to help people in your team add new workflows more easily.

注: GitHub 托管的运行器目前在 GitHub Enterprise Server 上不受支持。 您可以在 GitHub 公共路线图 上查看有关未来支持计划的更多信息。


Workflow templates 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 template and some or all of the work of writing the workflow will be done for you. 您可以使用工作流程模板作为基础来构建自定义工作流程,或按原样使用模板。 This not only saves time, it promotes consistency and best practice across your organization.

Creating a workflow template

Workflow templates can be created by users with write access to the organization's .github repository. The templates can then be used by organization members who have permission to create workflows.

This procedure demonstrates how to create a workflow template and metadata file. The metadata file describes how the template is presented to users when they are creating a new workflow.

  1. If it doesn't already exist, create a new public repository named .github in your organization.

  2. Create a directory named workflow-templates.

  3. Create your new workflow file inside the workflow-templates directory.

    If you need to refer to a repository's default branch, you can use the $default-branch placeholder. When a workflow is created using your template, the placeholder will be automatically replaced with the name of the repository's default branch.

    For example, this file named octo-organization-ci.yml demonstrates a basic workflow.

    name: Octo Organization CI
        branches: [ $default-branch ]
        branches: [ $default-branch ]
        runs-on: ubuntu-latest
          - uses: actions/checkout@v2
          - name: Run a one-line script
            run: echo Hello from Octo Organization
  4. Create a metadata file inside the workflow-templates directory. The metadata file must have the same name as the workflow file, but instead of the .yml extension, it must be appended with .properties.json. For example, this file named contains the metadata for a workflow file named octo-organization-ci.yml:

        "name": "Octo Organization Workflow",
        "description": "Octo Organization CI workflow template.",
        "iconName": "example-icon",
        "categories": [
        "filePatterns": [
    • name - Required. The name of the workflow template. This is displayed in the list of available templates.
    • description - Required. The description of the workflow template. This is displayed in the list of available templates.
    • iconName - Optional. Defines an icon for the workflow's entry in the template list. The iconName must be an SVG icon of the same name, and must be stored in the workflow-templates directory. For example, a SVG file named example-icon.svg is referenced as example-icon.
    • categories - Optional. Defines the language category of the workflow. When a user views the available templates, those templates that match the same language will feature more prominently. For information on the available language categories, see
    • filePatterns - Optional. Allows the template to be used if the user's repository has a file in its root directory that matches a defined regular expression.

To add another workflow template, add your files to the same workflow-templates directory. For example:

Workflow template files

Next steps

To continue learning about GitHub Actions, see "Using workflow templates."




所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。


或者, 了解如何参与。