mirror of
https://github.com/nektos/act.git
synced 2026-04-26 09:25:54 +03:00
[GH-ISSUE #2663] Globally available environment variables #1207
Labels
No labels
area/action
area/cli
area/docs
area/image
area/runner
area/workflow
backlog
confirmed/not-planned
kind/bug
kind/discussion
kind/external
kind/feature-request
kind/question
meta/duplicate
meta/invalid
meta/need-more-info
meta/resolved
meta/wontfix
meta/workaround
needs-work
pull-request
review/not-planned
size/M
size/XL
size/XXL
stale
stale-exempt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/act#1207
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Makeshift on GitHub (Feb 11, 2025).
Original GitHub issue: https://github.com/nektos/act/issues/2663
Act version
0.2.74
Feature description
Currently, act only makes variables (defined with
--var) available to workflows that explicitly reference thevarscontext.Given the command
act --workflows build.yml --job build --var SOME_VAR=foo, the following step will not outputfoo:But this one will:
We have self-hosted GitHub Actions runners that run in Kubernetes and are automatically provided with AWS credentials from their environment, without needing to specify any credential-related actions or interacting with GitHub context in any way.
This is difficult to replicate locally with act, because vars like
AWS_ACCESS_KEY_IDcannot be made available to the underlying AWS SDK running in the action within act unless you specifically set theenv:key in the workflow. Problematically, that then means that if we commit the workflow with theenv:key, then when the self-hosted runner picks up the workflow, the environment variables set in the self-hosted runner environment are overwritten.This means that for local testing, we need to either heavily modify our workflows, provide a pre-generated
.envfile to act (which does get injected globally, I think) or it's possible to use.envfiles, since they're injected globally, but I wanted to be able to use the new act vscode extension and was trying to avoid having to manually run a bunch of commands before invoking it.You can use secrets, this monstrosity in
.actrcsort-of works:but unfortunately secrets are not exposed to child actions as env vars, so none of the child actions that rely on these globally-available variables work.
My terrible workaround to this: as part of another action we happen to have that runs at the start of each workflow to enable extra debugging info if debug mode is enabled, I added an additional step that re-exports the passed-in secrets to put them into the job env scope.
This is uh, horrid, but works! Alternative suggestions very welcome.
@ChristopherHX commented on GitHub (Feb 11, 2025):
Is there a problem with
--env? (--varis a much newer concept of Actions)@Makeshift commented on GitHub (Feb 11, 2025):
Oh wow, I'm an idiot. Somehow I completely glossed
--envin the help 🤦. Thanks.