Skip to content

Commit 711de2b

Browse files
ajayknhubwriter
andauthored
Enable concurrency for reusable workflows (#23739)
Co-authored-by: hubwriter <hubwriter@github.com>
1 parent 8739a3e commit 711de2b

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

content/actions/learn-github-actions/contexts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ The following table indicates where each context and special function can be use
221221

222222
| Path | Context | Special functions |
223223
| ---- | ------- | ----------------- |
224-
| <code>concurrency</code> | <code>github</code> | |
224+
| <code>concurrency</code> | <code>github, inputs</code> | |
225225
| <code>env</code> | <code>github, secrets, inputs</code> | |
226226
| <code>jobs.&lt;job_id&gt;.concurrency</code> | <code>github, needs, strategy, matrix, inputs</code> | |
227227
| <code>jobs.&lt;job_id&gt;.container</code> | <code>github, needs, strategy, matrix, inputs</code> | |

content/actions/learn-github-actions/reusing-workflows.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ topics:
1818

1919
## Overview
2020

21-
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.
21+
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.
2222

23-
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 proved to be effective. Your organization can build up a library of reusable workflows that can be centrally maintained.
23+
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 proved to be effective. Your organization can build up a library of reusable workflows that can be centrally maintained.
2424

2525
The diagram below shows three build jobs on the left of the diagram. After each of these jobs completes successfully a dependent job called "Deploy" runs. This job calls a reusable workflow that contains three jobs: "Staging", "Review", and "Production." The "Production" deployment job only runs after the "Staging" job has completed successfully. Using a reusable workflow to run deployment jobs allows you to run those jobs for each build without duplicating code in workflows.
2626

@@ -67,7 +67,6 @@ Called workflows can access self-hosted runners from caller's context. This mean
6767
* Reusable workflows can't call other reusable workflows.
6868
* Reusable workflows stored within a private repository can only be used by workflows within the same repository.
6969
* Any environment variables set in an `env` context defined at the workflow level in the caller workflow are not propagated to the called workflow. For more information about the `env` context, see "[Context and expression syntax for GitHub Actions](/actions/reference/context-and-expression-syntax-for-github-actions#env-context)."
70-
* You can't set the concurrency of a called workflow from the caller workflow. For more information about `jobs.<job_id>.concurrency`, see "[Workflow syntax for GitHub Actions](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idconcurrency)."
7170
* The `strategy` property is not supported in any job that calls a reusable workflow.
7271

7372
## Creating a reusable workflow
@@ -77,13 +76,13 @@ Reusable workflows are YAML-formatted files, very similar to any other workflow
7776
For a workflow to be reusable, the values for `on` must include `workflow_call`:
7877

7978
```yaml
80-
on:
79+
on:
8180
workflow_call:
8281
```
8382
8483
### Using inputs and secrets in a reusable workflow
8584
86-
You can define inputs and secrets, which can be passed from the caller workflow and then used within the called workflow. There are three stages to using an input or a secret in a reusable workflow.
85+
You can define inputs and secrets, which can be passed from the caller workflow and then used within the called workflow. There are three stages to using an input or a secret in a reusable workflow.
8786
8887
1. In the reusable workflow, use the `inputs` and `secrets` keywords to define inputs or secrets that will be passed from a caller workflow.
8988
{% raw %}
@@ -112,10 +111,10 @@ You can define inputs and secrets, which can be passed from the caller workflow
112111
- uses: ./.github/actions/my-action@v1
113112
with:
114113
username: ${{ inputs.username }}
115-
token: ${{ secrets.envPAT }}
114+
token: ${{ secrets.envPAT }}
116115
```
117116
{% endraw %}
118-
In the example above, `envPAT` is an environment secret that's been added to the `production` environment. This environment is therefore referenced within the job.
117+
In the example above, `envPAT` is an environment secret that's been added to the `production` environment. This environment is therefore referenced within the job.
119118

120119
{% note %}
121120

@@ -153,7 +152,7 @@ jobs:
153152
- uses: ./.github/actions/my-action@v1
154153
with:
155154
username: ${{ inputs.username }}
156-
token: ${{ secrets.token }}
155+
token: ${{ secrets.token }}
157156
```
158157
{% endraw %}
159158

@@ -163,7 +162,7 @@ You call a reusable workflow by using the `uses` keyword. Unlike when you are us
163162

164163
[`jobs.<job_id>.uses`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_iduses)
165164

166-
You reference reusable workflow files using the syntax:
165+
You reference reusable workflow files using the syntax:
167166

168167
`{owner}/{repo}/{path}/{filename}@{ref}`
169168

@@ -191,7 +190,7 @@ When you call a reusable workflow, you can only use the following keywords in th
191190

192191
{% note %}
193192

194-
**Note:**
193+
**Note:**
195194

196195
* If `jobs.<job_id>.permissions` is not specified in the calling job, the called workflow will have the default permissions for the `GITHUB_TOKEN`. For more information, see "[Authentication in a workflow](/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token)."
197196
* The `GITHUB_TOKEN` permissions passed from the caller workflow can be only downgraded (not elevated) by the called workflow.
@@ -226,7 +225,7 @@ jobs:
226225

227226
## Using outputs from a reusable workflow
228227

229-
A reusable workflow may generate data that you want to use in the caller workflow. To use these outputs, you must specify them as the outputs of the reusable workflow.
228+
A reusable workflow may generate data that you want to use in the caller workflow. To use these outputs, you must specify them as the outputs of the reusable workflow.
230229

231230
The following reusable workflow has a single job containing two steps. In each of these steps we set a single word as the output: "hello" and "world." In the `outputs` section of the job, we map these step outputs to job outputs called: `output1` and `output2`. In the `on.workflow_call.outputs` section we then define two outputs for the workflow itself, one called `firstword` which we map to `output1`, and one called `secondword` which we map to `output2`.
232231

@@ -243,12 +242,12 @@ on:
243242
value: ${{ jobs.example_job.outputs.output1 }}
244243
secondword:
245244
description: "The second output string"
246-
value: ${{ jobs.example_job.outputs.output2 }}
247-
245+
value: ${{ jobs.example_job.outputs.output2 }}
246+
248247
jobs:
249248
example_job:
250249
name: Generate output
251-
runs-on: ubuntu-latest
250+
runs-on: ubuntu-latest
252251
# Map the job outputs to step outputs
253252
outputs:
254253
output1: ${{ steps.step1.outputs.firstword }}

0 commit comments

Comments
 (0)