1

I'm writing my own Docker Github Action and I need access to some Github environment variable, specifically to the GITHUB_WORKSPACE variable.

I assume the user has called the checkout@v2 action beforehand and in my action.yml the run section looks as follows

runs:
  using: 'docker'
  image: 'Dockerfile'
  args:
    - ${{ github.workspace }}

But I get the following error

Unrecognized named-value: 'github'. Located at position 1 within expression: github.workspace

How do I make the supposedly globally available Github environment variables accessible from my action?

1
  • This seems like a huge bug in actions Commented Apr 18, 2023 at 22:18

1 Answer 1

0

You do not need to do anything.

These variables are available directly in the container (in your action). They are injected by GitHub. In the action.yaml you do not need to specify anything and you can then access them in you code.

Note: The input values are also injected, but they start with INPUT_ and are capitalized.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the answer - where is the part about INPUT_ is documented?
It is referenced in the docs for metadata syntax
Can you add an example of the original action code properly accessing the github.workspace variable?
I need to be able to access these variables specifically in the args so that I can add logic such as: - ${{ github.ref != 'refs/heads/main' && '--dry-run' }} Is there no way to actually access the github variable in the args?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.