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

Description of vars usage is not acurate #34037

Closed
1 task done
withakay opened this issue Jul 20, 2024 · 1 comment
Closed
1 task done

Description of vars usage is not acurate #34037

withakay opened this issue Jul 20, 2024 · 1 comment
Labels
content This issue or pull request belongs to the Docs Content team triage Do not begin working on this issue until triaged by the team

Comments

@withakay
Copy link

withakay commented Jul 20, 2024

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?

The 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 a variable defined in the environment 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 accurate.

Additional information

Note this is a duplicate of the issue here which was closed due to a failure to reproduce.

I am still able to reproduce this issue and have created a repository to demonstrate this here: https://github.com/withakay/runner-env-var-repro

Perhaps the tester made a mistake when configuring the repository? 🤷‍♂️

To reproduce

I will outline the steps to reproduce manually, but I would advise forking the reproduction repository and then skipping to step 2

  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 an environment in the repository called 'dev'
  2. Add a variable to the 'dev' environment called RUNNER with a value of ubuntu-latest
  3. Run the Workflow and observe it failing in

It is crucial when reproducing that the RUNNER variable is added to the 'dev' environment. Adding it to a repository or organisation scoped variable will produce a false positive

@withakay withakay added the content This issue or pull request belongs to the Docs Content team label Jul 20, 2024
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Jul 20, 2024
@nguyenalex836
Copy link
Contributor

Closing per comment here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content This issue or pull request belongs to the Docs Content team triage Do not begin working on this issue until triaged by the team
Projects
None yet
Development

No branches or pull requests

2 participants