【问题标题】:Is there a way to dynamically make github actions secrets available at runtime without explicitly defining each variable in your yaml?有没有一种方法可以在运行时动态地使 github 操作机密可用,而无需在 yaml 中显式定义每个变量?
【发布时间】:2021-03-11 19:30:39
【问题描述】:

在其当前格式中,您可以在存储库 UI 中定义 git hub 机密,并将它们添加到您的 github 操作 CI 中,如下所示:

- name: test secrets
  shell: bash
  run: 
  env:
     SECRET_1: ${{ secrets.secret_1 }}
     SECRET_2: ${{ secrets.secret_2 }}

但是,如果您想动态添加附加到该环境的所有机密,特别是如果您的机密定期更改,这种方法会很麻烦。使用上述方法,每次更改都需要部署不方便的代码。有没有人提出解决方案?或者是否有任何内置语法可以加载所有秘密?还是遵循某种模式的秘密?

【问题讨论】:

    标签: github github-actions


    【解决方案1】:

    不,这是不可能的(而且将来也不会)。正如这里所写,你必须清楚地表明你想在your workflow 中使用什么秘密,就像这里:

    steps:
      - name: Hello world action
        with: # Set the secret as an input
          super_secret: ${{ secrets.SuperSecret }}
        env: # Or as an environment variable
          super_secret: ${{ secrets.SuperSecret }}
    

    这是有目的的。由于作者想强制开发人员使用所需的确切秘密。这只是解决安全问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-17
      • 1970-01-01
      • 1970-01-01
      • 2014-08-14
      • 1970-01-01
      • 2019-08-30
      • 1970-01-01
      相关资源
      最近更新 更多