Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com> Co-authored-by: jc-clark <jc-clark@github.com>
5.7 KiB
title, shortTitle, intro, redirect_from, versions, type, topics
| title | shortTitle | intro | redirect_from | versions | type | topics | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Creating starter workflows for your organization | Create starter workflows | Learn how you can create starter workflows to help people in your team add new workflows more easily. |
|
|
tutorial |
|
{% data reusables.actions.enterprise-github-hosted-runners %}
Overview
{% data reusables.actions.workflow-organization-templates %}
{% data reusables.actions.starter-workflow-categories %}
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.
{% ifversion fpt %} Starter workflows created by users can only be used to create workflows in public repositories. Organizations using {% data variables.product.prodname_ghe_cloud %} can also use starter workflows to create workflows in private repositories. For more information, see the {% data variables.product.prodname_ghe_cloud %} documentation. {% endif %}
{% note %}
Note: To avoid duplication among starter workflows you can call reusable workflows from within a workflow. This can help make your workflows easier to maintain. For more information, see "AUTOTITLE."
{% endnote %}
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.
-
If it doesn't already exist, create a new public repository named
.githubin your organization. -
Create a directory named
workflow-templates. -
Create your new workflow file inside the
workflow-templatesdirectory.If you need to refer to a repository's default branch, you can use the
$default-branchplaceholder. When a workflow is created the placeholder will be automatically replaced with the name of the repository's default branch.{% ifversion ghes %} {% note %}
Note: The following values in the
runs-onkey are also treated as placeholders:- "ubuntu-latest" is replaced with "[ self-hosted ]"
- "windows-latest" is replaced with "[ self-hosted, windows ]"
- "macos-latest" is replaced with "[ self-hosted, macOS ]"
{% endnote %}{% endif %}
For example, this file named
octo-organization-ci.ymldemonstrates a basic workflow.name: Octo Organization CI on: push: branches: [ $default-branch ] pull_request: branches: [ $default-branch ] jobs: build: runs-on: ubuntu-latest steps: - uses: {% data reusables.actions.action-checkout %} - name: Run a one-line script run: echo Hello from Octo Organization -
Create a metadata file inside the
workflow-templatesdirectory. The metadata file must have the same name as the workflow file, but instead of the.ymlextension, it must be appended with.properties.json. For example, this file namedocto-organization-ci.properties.jsoncontains the metadata for a workflow file namedocto-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 is displayed in the list of workflows.iconNamecan one of the following types:- An SVG file that is stored in the
workflow-templatesdirectory. To reference a file, the value must be the file name without the file extension. For example, an SVG file namedexample-icon.svgis referenced asexample-icon. - An icon from {% data variables.product.prodname_dotcom %}'s set of Octicons. To reference an octicon, the value must be
octicon <icon name>. For example,octicon smiley.
- An SVG file that is stored in the
-
categories- Optional. Defines the categories that the workflow is shown under. You can use category names from the following lists:- General category names from the starter-workflows repository.
- Linguist languages from the list in the linguist repository.
- Supported tech stacks from the list in the starter-workflows repository.
-
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.
Next steps
To continue learning about {% data variables.product.prodname_actions %}, see "AUTOTITLE."