Skip to content

Commit 37a65d7

Browse files
authored
Merge pull request #17571 from github/repo-sync
repo sync
2 parents e4bd305 + 4142881 commit 37a65d7

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

content/actions/using-workflows/reusing-workflows.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ You can define inputs and secrets, which can be passed from the caller workflow
103103
required: true
104104
```
105105
{% endraw %}
106+
{% if actions-inherit-secrets-reusable-workflows %}
107+
For details of the syntax for defining inputs and secrets, see [`on.workflow_call.inputs`](/actions/reference/workflow-syntax-for-github-actions#onworkflow_callinputs), [`on.workflow_call.secrets`](/actions/reference/workflow-syntax-for-github-actions#onworkflow_callsecrets) and [`on.workflow_call.secrets.inherit`](/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callsecretsinherit).
108+
1. In the reusable workflow, reference the input or secret that you defined in the `on` key in the previous step. If the secrets are inherited using `secrets: inherit`, you can reference them even if they are not defined in the `on` key.
109+
{%- else %}
106110
For details of the syntax for defining inputs and secrets, see [`on.workflow_call.inputs`](/actions/reference/workflow-syntax-for-github-actions#onworkflow_callinputs) and [`on.workflow_call.secrets`](/actions/reference/workflow-syntax-for-github-actions#onworkflow_callsecrets).
107111
1. In the reusable workflow, reference the input or secret that you defined in the `on` key in the previous step.
112+
{%- endif %}
108113

109114
{% raw %}
110115
```yaml
@@ -189,6 +194,7 @@ When you call a reusable workflow, you can only use the following keywords in th
189194
* [`jobs.<job_id>.with.<input_id>`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idwithinput_id)
190195
* [`jobs.<job_id>.secrets`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idsecrets)
191196
* [`jobs.<job_id>.secrets.<secret_id>`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idsecretssecret_id)
197+
{% if actions-inherit-secrets-reusable-workflows %}* [`jobs.<job_id>.secrets.inherit`](/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callsecretsinherit){% endif %}
192198
* [`jobs.<job_id>.needs`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds)
193199
* [`jobs.<job_id>.if`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif)
194200
* [`jobs.<job_id>.permissions`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idpermissions)

content/actions/using-workflows/workflow-syntax-for-github-actions.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,42 @@ jobs:
157157
```
158158
{% endraw %}
159159

160+
{% if actions-inherit-secrets-reusable-workflows %}
161+
162+
#### `on.workflow_call.secrets.inherit`
163+
164+
Use the `inherit` keyword to pass all the calling workflow's secrets to the called workflow. This includes all secrets the calling workflow has access to, namely organization, repository, and environment secrets. The `inherit` keyword can be used to pass secrets across repositories within the same organization, or across organizations within the same enterprise.
165+
166+
#### Example
167+
168+
{% raw %}
169+
170+
```yaml
171+
on:
172+
workflow_dispatch:
173+
174+
jobs:
175+
pass-secrets-to-workflow:
176+
uses: ./.github/workflows/called-workflow.yml
177+
secrets: inherit
178+
```
179+
180+
```yaml
181+
on:
182+
workflow_call:
183+
184+
jobs:
185+
pass-secret-to-action:
186+
runs-on: ubuntu-latest
187+
steps:
188+
- name: Use a repo or org secret from the calling workflow.
189+
uses: echo ${{ secrets.CALLING_WORKFLOW_SECRET }}
190+
```
191+
192+
{% endraw %}
193+
194+
{%endif%}
195+
160196
#### `on.workflow_call.secrets.<secret_id>`
161197

162198
A string identifier to associate with the secret.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reference: #6920
2+
# Documentation for inheriting secrets from the calling workflow
3+
versions:
4+
fpt: '*'
5+
ghec: '*'
6+
ghes: '>= 3.6'
7+
ghae:

data/reusables/actions/pass-inputs-to-reusable-workflows.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,19 @@ jobs:
1111
envPAT: ${{ secrets.envPAT }}
1212
```
1313
{% endraw %}
14+
15+
{% if actions-inherit-secrets-reusable-workflows %}
16+
Workflows that call reusable workflows in the same organization or enterprise can use the `inherit` keyword to implicitly pass the secrets.
17+
18+
{% raw %}
19+
```yaml
20+
jobs:
21+
call-workflow-passing-data:
22+
uses: octo-org/example-repo/.github/workflows/reusable-workflow.yml@main
23+
with:
24+
username: mona
25+
secrets: inherit
26+
```
27+
{% endraw %}
28+
29+
{%endif%}

0 commit comments

Comments
 (0)