Skip to content

Description of vars usage is not acurate  #33389

@withakay

Description

@withakay

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/contexts#example-usage-of-the-vars-context

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

To article states "This example workflow shows how configuration variables set at the repository, environment, or organization levels are automatically available using the vars context."

This is not acurate. In the below example where vars.RUNNER is variables defined in the environement dev (that is to say not at the repository or organisation level) then vars.RUNNER will not be evaluated and you can expect an error like:

Error when evaluating 'runs-on' for job 'test-job'. .github/workflows/test-job.yaml (Line: 26, Col: 14): Unexpected value ''

  test-job:
    name: "Can echo Hello World!"
    environment: "dev"
    runs-on: ${{vars.RUNNER}}
    steps:
      - name: hello-world
        run: echo "Hello World!"

It seems to me either the article is incorrect or there is a bug in the github actions engine as the described behaviour is not acurate.

Additional information

To reproduce

  1. create a new workflow
name: "Runner var test"
on:
  workflow_dispatch:


jobs:
  hello-world-job:
    name: "Can echo Hello World!"
    environment: "dev"
    runs-on: ${{vars.RUNNER}}
    steps:
      - name: hello-world
        run: echo "Hello World!"
  1. Create and environment in the repository and add a variable called RUNNER with a value of ubuntu-latest
  2. Run the Workflow and observe it failing in

Metadata

Metadata

Assignees

Labels

actionsThis issue or pull request should be reviewed by the docs actions teamcontentThis issue or pull request belongs to the Docs Content teamhelp wantedAnyone is welcome to open a pull request to fix this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions