Skip to content

Clarify vars context availability in composite actions #46232

Description

@vaclavbarta

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/reference/workflows-and-actions/contexts

https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-composite-action

What part(s) of the article would you like to see updated?

The documentation is unclear about whether the vars context is available inside composite actions.

The contexts reference lists vars as an available context, which can reasonably lead users to assume that this works inside a composite action:

runs:
  using: composite
  steps:
    - shell: bash
      run: echo "${{ vars.AWS_REGION }}"

However, the Composite Actions ADR states:

"Composite actions should leverage inputs to get values they need, they will not have full access to the context objects."

There is also an implementation detail documented by a runner collaborator in actions/runner#4311: variables are filtered based on references made directly in the calling job, so a vars reference used only inside a composite action may not be available to the runner.

Could the composite actions documentation explicitly clarify that values required by a composite action should be passed through inputs, including values originating from vars?

For example:

- uses: ./my-action
  with:
    region: ${{ vars.AWS_REGION }}

and then inside the composite action:

${{ inputs.region }}

This would make the relationship between the general contexts documentation and the more limited context availability of composite actions clearer.

Thanks

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentThis issue or pull request belongs to the Docs Content teamtriageDo not begin working on this issue until triaged by the team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions