访问本地env文件中的github秘密
有没有办法在本地env文件中访问github秘密?因此,而不是直接保存在env文件中,而是引用github秘密。我已经看到,github秘密可以在工作流程中使用,但我主要需要在env文件中具有值。
Is there a way to access GitHub secrets in a local env file? So instead of having a secret saved directly in the env file it would reference a GitHub secret. I've seen that the GitHub secrets can be used within a workflow but I mainly just need to have the values in the env file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可能会混淆事情。
本地env文件无法访问变量,而是您的代码读取ENV文件并使用这些变量。
如果您使用 dotenv ,此工具将读取您的Env文件,并在定义的情况下覆盖它们变量直接在环境上。
您可以使用将您的github秘密作为env变量导出的动作工作流程(披露:我是作者),因此最后一部分(替代)只能使用。
一个示例是:
您可以将其转换为:
链接到该操作,其中包含有关配置的更多文档: https://github.com/onaips/secrets-to-env-action
请参阅此相关的。
I think you might be confusing things.
A local env file does not access variables, instead, your code reads the env file and uses those variables.
If you use something like dotenv, this tool will read your env files, and optionally override them if you defined the variables directly on the environment.
You can use an action workflow (disclosure: i'm the author) that exports your github secrets as env variables, so last part (overrides) would just work.
An example would be:
You could convert it to:
Link to the action, which contains more documentation about configuration: https://github.com/oNaiPs/secrets-to-env-action
See this related SO post.