简体   繁体   English

Github 操作可重用工作流秘密不工作

[英]Github Actions Reusable Workflows Secrets Not working

I have a simple scenario with reusable workflows and secrets which doesn't work as the secrets are empty.我有一个简单的场景,其中包含可重用的工作流和机密,但由于机密为空,所以无法正常工作。

I have 3 GH repositories:我有 3 个 GH 存储库:

  1. Microservice code - contains the code to runs the workflows from the domain gh actions repo微服务代码——包含从域 gh actions repo 运行工作流的代码
  2. Domain GH Workflows repo - contains the github action secrets for the domain and uses the reusable workflows from the core devops repository Domain GH Workflows repo - 包含域的 github 操作秘密,并使用来自核心 devops 存储库的可重用工作流
  3. Core GH Workflows repo - contains generic workflows with many parameters that could be passed by other repositories Core GH Workflows repo - 包含具有许多参数的通用工作流,这些参数可以由其他存储库传递

I have added the domain secrets (such as aws access key and aws secret access key) to the domain Domain GH Workflows and passed it with the named secrets to the given workflow using the tutorial from the GH - I do not want to use the "inherit" keyword, as i have to use the parametrized version.我已将域机密(例如 aws 访问密钥和 aws 秘密访问密钥)添加到域 Domain GH Workflows 并使用 GH 中的教程将其与命名机密一起传递到给定的工作流 - 我不想使用“ inherit”关键字,因为我必须使用参数化版本。

However, only the empty strings are passed, even though I have added those kyes to the Github Repository Secrets of the Domain repository.但是,只有空字符串被传递,即使我已经将这些 kyes 添加到域存储库的 Github 存储库秘密中。 I have tried also adding it to the environment and using the environment value in the workflows in any part of the flow (microservice repo and domain gh workflow repo).我也尝试过将它添加到环境中,并在流程的任何部分(微服务回购和域 gh 工作流回购)的工作流中使用环境值。

Do you have any idea of why is it happening and what could be done to fix the problems that I am facing or achieve the similar results with a different approach?您是否知道为什么会发生这种情况以及可以采取哪些措施来解决我面临的问题或使用不同的方法获得类似的结果?

When you don't want to use the inherit keyword, you need to set each secret in the reusable workflow workflow_call trigger configuration, and share each secret from the main workflow (calling the reusable) as secrets inputs.当您不想使用inherit关键字时,您需要在可重用工作流workflow_call触发器配置中设置每个秘密,并将来自主工作流(调用可重用)的每个秘密共享为秘密输入。

However, in that case, you can only use secrets from the repository workflow calling the reusable workflow.但是,在这种情况下,您只能使用调用可重用工作流的存储库工作流中的机密。

Note: If you want to avoid duplicating secrets between repositories, there is also the solution of using Organization Secrets to share those secrets in different repository, storing them in only one place.注意:如果你想避免在存储库之间重复秘密,还有使用组织秘密在不同存储库中共享这些秘密的解决方案,将它们存储在一个地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM