bluesummers
bluesummers

Reputation: 12607

Accessing Github environment variables in custom Github Action

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?

Upvotes: 1

Views: 2424

Answers (1)

Denis Duev
Denis Duev

Reputation: 611

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.

Upvotes: 1

Related Questions