【问题标题】:GitHub Codespace secrets when using VSCode devcontainers locally本地使用 VSCode 开发容器时的 GitHub Codespace 机密
【发布时间】:2022-06-15 18:10:15
【问题描述】:

我使用 GCP 服务帐户文件作为 GitHub Codespaces 机密,并且可以从 Codespace 容器 as explained here 访问它。

现在,我还想支持在没有 GitHub Codespaces 但仍使用 VSCode 开发容器的情况下进行本地开发。

我还在本地文件系统上保存服务帐户文件,但在 git 存储库之外(出于显而易见的原因)。我应该如何引用它?

【问题讨论】:

    标签: environment-variables vscode-devcontainer github-codespaces


    【解决方案1】:

    您可以使用devcontainer.json 中的mounts 属性。 Codespaces 会忽略 bind 挂载(更多信息可在 documentation 中找到),因此您应该能够从本地文件系统挂载文件,而不会影响您的 Codespaces 的构建/运行方式。

    【讨论】:

      【解决方案2】:

      您可以使用terminal.integrated.env.linux 在您的settings.json 文件中传递秘密。

      您可以使用settingsSync.ignoredSettings 数组禁用设置同步:

      {
        "terminal.integrated.env.linux": {
          "GITHUB_TOKEN": "<your-token>"
        },
        "settingsSync.ignoredSettings": [
          "terminal.integrated.env.linux"
        ]
      }
      

      【讨论】:

        猜你喜欢
        • 2021-01-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-13
        相关资源
        最近更新 更多