Skip to content

Commit 3d3c6c0

Browse files
authored
Merge pull request #39235 from github/repo-sync
Repo sync
2 parents bc943e4 + f295006 commit 3d3c6c0

File tree

11 files changed

+531
-504
lines changed

11 files changed

+531
-504
lines changed

content/actions/concepts/workflows-and-actions/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ children:
99
- /about-workflows
1010
- /variables
1111
- /avoiding-duplication
12+
- /reusable-workflows
1213
- /about-custom-actions
1314
- /contexts
1415
- /expressions
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Reusable workflows
3+
shortTitle: Reusable workflows
4+
intro: Learn how to avoid duplication when creating a workflow by reusing existing workflows.
5+
versions:
6+
fpt: '*'
7+
ghec: '*'
8+
ghes: '*'
9+
---
10+
11+
## About reusable workflows
12+
13+
Rather than copying and pasting from one workflow to another, you can make workflows reusable. You and anyone with access to the reusable workflow can then call the reusable workflow from another workflow.
14+
15+
Reusing workflows avoids duplication. This makes workflows easier to maintain and allows you to create new workflows more quickly by building on the work of others, just as you do with actions. Workflow reuse also promotes best practice by helping you to use workflows that are well designed, have already been tested, and have been proven to be effective. Your organization can build up a library of reusable workflows that can be centrally maintained.
16+
17+
The diagram below shows an in-progress workflow run that uses a reusable workflow.
18+
19+
* After each of three build jobs on the left of the diagram completes successfully, a dependent job called "Deploy" is run.
20+
* The "Deploy" job calls a reusable workflow that contains three jobs: "Staging", "Review", and "Production."
21+
* The "Production" deployment job only runs after the "Staging" job has completed successfully.
22+
* When a job targets an environment, the workflow run displays a progress bar that shows the number of steps in the job. In the diagram below, the "Production" job contains 8 steps, with step 6 currently being processed.
23+
* Using a reusable workflow to run deployment jobs allows you to run those jobs for each build without duplicating code in workflows.
24+
25+
![Diagram of a workflow calling a reusable workflow.](/assets/images/help/actions/reusable-workflows-ci-cd.png)
26+
27+
A workflow that uses another workflow is referred to as a "caller" workflow. The reusable workflow is a "called" workflow. One caller workflow can use multiple called workflows. Each called workflow is referenced in a single line. The result is that the caller workflow file may contain just a few lines of YAML, but may perform a large number of tasks when it's run. When you reuse a workflow, the entire called workflow is used, just as if it was part of the caller workflow.
28+
29+
If you reuse a workflow from a different repository, any actions in the called workflow run as if they were part of the caller workflow. For example, if the called workflow uses `actions/checkout`, the action checks out the contents of the repository that hosts the caller workflow, not the called workflow.
30+
31+
You can view the reused workflows referenced in your {% data variables.product.prodname_actions %} workflows as dependencies in the dependency graph of the repository containing your workflows. For more information, see “[About the dependency graph](/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph).”
32+
33+
## Reusable workflows versus composite actions
34+
35+
Reusable workflows and composite actions both help you to avoid duplication. Whereas reusable workflows allow you to reuse an entire workflow, with multiple jobs and steps, composite actions combine multiple steps that you can then run within a job step, just like any other action. For more information, see [AUTOTITLE](/actions/using-workflows/avoiding-duplication).
36+
37+
## Reusable workflows and workflow templates
38+
39+
Workflow templates allow everyone in your organization who has permission to create workflows to do so more quickly and easily. When people create a new workflow, they can choose a workflow template and some or all of the work of writing the workflow will be done for them. Within a workflow template, you can also reference reusable workflows to make it easy for people to benefit from reusing centrally managed workflow code. If you use a commit SHA when referencing the reusable workflow, you can ensure that everyone who reuses that workflow will always be using the same YAML code. However, if you reference a reusable workflow by a tag or branch, be sure that you can trust that version of the workflow. For more information, see [AUTOTITLE](/actions/security-guides/security-hardening-for-github-actions#reusing-third-party-workflows).
40+
41+
For more information, see [AUTOTITLE](/actions/using-workflows/creating-starter-workflows-for-your-organization).
42+
43+
## Next steps
44+
45+
To start reusing your workflows, see [AUTOTITLE](/actions/how-tos/sharing-automations/reuse-workflows).
46+
47+
To find information on the intricacies of reusing workflows, see [AUTOTITLE](/actions/reference/reusable-workflows-reference).

content/actions/how-tos/sharing-automations/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ redirect_from:
1515
- /actions/sharing-automations
1616
children:
1717
- /creating-actions
18-
- /reusing-workflows
18+
- /reuse-workflows
1919
- /creating-workflow-templates-for-your-organization
2020
- /sharing-actions-and-workflows-from-your-private-repository
2121
- /sharing-actions-and-workflows-with-your-organization

0 commit comments

Comments
 (0)