Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarifies outputs in reusable workflows #32544

Merged
merged 4 commits into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion content/actions/using-workflows/reusing-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
You cannot directly use reusable workflows defined on {% data variables.product.prodname_dotcom_the_website %}. Instead store a copy of the reusable workflow on {% data variables.location.product_location %}, and call the workflow from that path.

{% elsif actions-workflow-policy %}, and your {% ifversion ghec %}enterprise{% else %}organization{% endif %} allows you to use public reusable workflows.{% endif %}{% ifversion ghes or ghec %}
- The called workflow is stored in an internal repository and the settings for that repository allow it to be accessed. For more information, see {% ifversion internal-actions %}"[AUTOTITLE](/actions/creating-actions/sharing-actions-and-workflows-with-your-enterprise){% else %}"[AUTOTITLE](/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#allowing-access-to-components-in-an-internal-repository){% endif %}."{% endif %}{% ifversion private-actions %}

Check warning on line 58 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'private-actions' includes all possible versions and will always be true
- The called workflow is stored in a private repository and the settings for that repository allow it to be accessed. For more information, see {% ifversion ghes or ghec %}"[AUTOTITLE](/actions/creating-actions/sharing-actions-and-workflows-with-your-enterprise)."{% else %}"[AUTOTITLE](/actions/creating-actions/sharing-actions-and-workflows-with-your-organization)" and "[AUTOTITLE](/actions/creating-actions/sharing-actions-and-workflows-from-your-private-repository)."{% endif %}
{% endif %}

Expand Down Expand Up @@ -87,7 +87,7 @@
{% ifversion private-actions %}{% else %}- Reusable workflows stored within a private repository can only be used by workflows within the same repository.{% endif %}
{% ifversion actions-reusable-workflow-matrix %}{% else %}* The `strategy` property is not supported in any job that calls a reusable workflow.{% endif %}
- 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, see "[AUTOTITLE](/actions/learn-github-actions/variables)" and "[AUTOTITLE](/actions/learn-github-actions/contexts#env-context)."
- Similarly, environment variables set in the `env` context, defined in the called workflow, are not accessible in the `env` context of the caller workflow. Instead, you must use outputs of the reusable workflow. For more information, see "[Using outputs from a reusable workflow](#using-outputs-from-a-reusable-workflow)."

Check warning on line 90 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'nested-reusable-workflow' includes all possible versions and will always be true
- To reuse variables in multiple workflows, set them at the organization, repository, or environment levels and reference them using the `vars` context. For more information see "[AUTOTITLE](/actions/learn-github-actions/variables)" and "[AUTOTITLE](/actions/learn-github-actions/contexts#vars-context)."
- Reusable workflows are called directly within a job, and not from within a job step. You cannot, therefore, use `GITHUB_ENV` to pass values to job steps in the caller workflow.

Expand All @@ -96,8 +96,8 @@
Reusable workflows are YAML-formatted files, very similar to any other workflow file. As with other workflow files, you locate reusable workflows in the `.github/workflows` directory of a repository. Subdirectories of the `workflows` directory are not supported.

For a workflow to be reusable, the values for `on` must include `workflow_call`:

Check warning on line 99 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'private-actions' includes all possible versions and will always be true
```yaml

Check warning on line 100 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'actions-reusable-workflow-matrix' includes all possible versions and will always be true
on:
workflow_call:
```
Expand Down Expand Up @@ -135,7 +135,7 @@
1. In the reusable workflow, reference the input or secret that you defined in the `on` key in the previous step.
{%- endif %}

{% raw %}

Check warning on line 138 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'actions-inherit-secrets-reusable-workflows' includes all possible versions and will always be true

```yaml
jobs:
Expand Down Expand Up @@ -223,7 +223,7 @@

{% raw %}

```yaml copy

Check warning on line 226 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'actions-reusable-workflow-matrix' includes all possible versions and will always be true
jobs:
ReuseableMatrixJobForDeployment:
strategy:
Expand Down Expand Up @@ -259,10 +259,10 @@
- [`jobs.<job_id>.permissions`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idpermissions)

{% note %}

Check warning on line 262 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'actions-inherit-secrets-reusable-workflows' includes all possible versions and will always be true
**Note:**

- 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 "[AUTOTITLE](/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token)."

Check warning on line 265 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'actions-reusable-workflow-matrix' includes all possible versions and will always be true
- The `GITHUB_TOKEN` permissions passed from the caller workflow can be only downgraded (not elevated) by the called workflow.
- If you use `jobs.<job_id>.concurrency.cancel-in-progress: true`, don't use the same value for `jobs.<job_id>.concurrency.group` in the called and caller workflows as this will cause the workflow that's already running to be cancelled. A called workflow uses the name of its caller workflow in {% raw %}${{ github.workflow }}{% endraw %}, so using this context as the value of `jobs.<job_id>.concurrency.group` in both caller and called workflows will cause the caller workflow to be cancelled when the called workflow runs.

Expand Down Expand Up @@ -311,7 +311,7 @@

```yaml copy
name: Reusable workflow

Check warning on line 314 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'nested-reusable-workflow' includes all possible versions and will always be true
on:
workflow_call:

Expand Down Expand Up @@ -363,10 +363,14 @@
If a reusable workflow that sets an output is executed with a matrix strategy, the output will be the output set by the last successful completing reusable workflow of the matrix which actually sets a value.
That means if the last successful completing reusable workflow sets an empty string for its output, and the second last successful completing reusable workflow sets an actual value for its output, the output will contain the value of the second last completing reusable workflow.{% endif %}

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`.
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`.

The `value` must be set to the value of a job-level output within the called workflow. Step-level outputs must first be mapped to job-level outputs as shown below.

For more information, see "[AUTOTITLE](/actions/using-jobs/defining-outputs-for-jobs#overview)" and "[AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_calloutputs)."

{% raw %}

Check warning on line 373 in content/actions/using-workflows/reusing-workflows.md

View workflow job for this annotation

GitHub Actions / lint-content

Liquid `ifversion` (and `elsif`) should not always be true

The Liquid ifversion condition 'actions-reusable-workflow-matrix' includes all possible versions and will always be true
```yaml copy
name: Reusable workflow

Expand Down