Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 3

Use Global Environment Variables in with clause of workflow

Solved! Go to Solution.

I'm currently writing an action that can execute ansible playbooks.
My problems is the extra-vars section.

Due to the fact that it's not possible to pass arrays into the dockerfile I need to do a workaround.
Mine is to pass a String like this:

with:
  ...
  extraVars: 'my_first_extra=${{ GITHUB_ACTOR }} my_second_one=${{ GITHUB_SHA }}'

This doesn't work out for me because the workflow is complaining like this:

### ERRORED 11:48:48Z

- Your workflow file was invalid: The pipeline is not valid. .github/workflows/main.yml (Line: 23, Col: 22): Unrecognized named-value: 'GITHUB_ACTOR'. Located at position 1 within expression: GITHUB_ACTOR


What am I doing wrong? How can i use global environment variables as "with" variable?

I know that it's possible to use secrets like ```secrets.MY_SECRET```` 
Is there a clue how to do that with global environment variables like ```env.GITHUB_SHA```?

2 Replies
Solution
Copilot Lvl 3
Message 2 of 3

Re: Use Global Environment Variables in with clause of workflow

Embarassing....
A little further reading brought me to the solution which one can find here:
https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-express...

 

It's almost the same as with input variables which convert from 'whateverMyVariable-NameIs' to 'INPUT_WHATEVERMYVARIABLE_NAMEIS'.
The same applies here: github.sha becomes GITHUB_SHA

with:
  ...
  extraVars: 'my_first_extra=${{ github.actor }} my_second_one=${{ github.sha }}'
Community Manager
Message 3 of 3

Re: Use Global Environment Variables in with clause of workflow

We appreciate you coming back and sharing @ppoetz, this post might help another user in the future. In the meantime, we're looking forward to seeing you around!


Best,
AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!