Skip to content

How to use env vars or constants in composite actions? #51280

Answered by mildmojo
mildmojo asked this question in Actions
Discussion options

You must be logged in to vote

Answer

There's no top-level YAML way to declare a variable scoped to a composite action and available in step options, like you can with workflows and the top-level env. 😔 Maybe they'll add it someday! See a workaround below.

Docker actions do have a runs.env that lets you declare variables at a top-ish level, but those aren't composite actions, and I haven't tested to see if that modifies the caller's env.

Thanks to everyone who replied!

Details

Here's what I learned from the replies, docs, and my own testing:

  • A workflow's top-level env, jobs.<id>.env, and the space you manipulate by writing to $GITHUB_ENV in a shell command (in both workflows and actions) are all the same globally-shar…

Replies: 12 comments 15 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mildmojo
Comment options

Comment options

You must be logged in to vote
3 replies
@joeatnetgear
Comment options

@lschoenepxc
Comment options

@leemeador
Comment options

Comment options

You must be logged in to vote
3 replies
@LesnyRumcajs
Comment options

@TWiStErRob
Comment options

@mildmojo
Comment options

Comment options

You must be logged in to vote
5 replies
@lschoenepxc
Comment options

@mildmojo
Comment options

@lschoenepxc
Comment options

@TWiStErRob
Comment options

@mildmojo
Comment options

Answer selected by mildmojo
Comment options

You must be logged in to vote
1 reply
@mildmojo
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mildmojo
Comment options

Comment options

You must be logged in to vote
1 reply
@mildmojo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Question