-
Notifications
You must be signed in to change notification settings - Fork 62.7k
Open
Labels
contentThis issue or pull request belongs to the Docs Content teamThis issue or pull request belongs to the Docs Content teamgithub_actionsPull requests that update GitHub Actions codePull requests that update GitHub Actions code
Description
Code of Conduct
- I have read and agree to the GitHub Docs project's Code of Conduct
What article on docs.github.com is affected?
What changes are you suggesting?
Add a Limitations section to the reusable workflows documentation to clarify that reusable workflows do not currently support passing custom environment variables directly, except for default environment variables like github.head_ref
.
Highlight a workaround using job outputs to pass dynamic values.
Additional information
Calling reusable workflows with a value like ${{ github.event.pull_request.number }} will not work as expected.
Example of What Does Not Work:
name: Call a reusable workflow
on:
pull_request:
branches:
- main
jobs:
call-workflow:
uses: octo-org/example-repo/.github/workflows/workflow-A.yml@v1
with:
pr_number: ${{ github.event.pull_request.number }}
Workaround: Pass env values using a job output.
Example of Workaround:
name: Call a reusable workflow
on:
pull_request:
branches:
- main
jobs:
setup-env:
runs-on: ubuntu-latest
outputs:
pr_num: ${{ steps.set-pr-number.outputs.pr_num }}
steps:
- name: Set pull request number
id: set-pr-number
run: |
echo "pr_num=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
call-workflow:
needs: setup-env
uses: octo-org/example-repo/.github/workflows/workflow-A.yml@v1
with:
pr_number: ${{ needs.setup-env.outputs.pr_num }}
Metadata
Metadata
Assignees
Labels
contentThis issue or pull request belongs to the Docs Content teamThis issue or pull request belongs to the Docs Content teamgithub_actionsPull requests that update GitHub Actions codePull requests that update GitHub Actions code