【问题标题】:Missing Master Key Error Github Action with test.key stored as a secret缺少主密钥错误 Github 操作,测试密钥存储为秘密
【发布时间】:2023-02-10 00:58:24
【问题描述】:

我对 Rails Credentials 感到疯狂! 启动我的 Github Action 测试时,我有一个 Missing Master Key Error

我有

  1. 使用rails credential:edit -e test命令生成credentials/test.keycredentials/test.yml.enc

  2. test.key 的内容存储在 GITHUB Actions Secret 中

  3. 在我的 Github Action 中引用了它

    env:
      RAILS_ENV: test      
      RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
    

    仍然说“丢失钥匙”... 我也在生产中做了同样的事情(就像之前 master.key 存储在 Github 上一样!!)

【问题讨论】:

    标签: ruby-on-rails github-actions credentials


    【解决方案1】:

    在开始运行测试之前,您可以运行以下命令在 config 下添加密钥。

    echo "$RAILS_MASTER_KEY" > config/master.key

    【讨论】:

    • 谢谢,它没有用。我回过头来,一步步找到了方法。缺乏文档和技术债务使得很难理解真正的加密密钥在哪里
    【解决方案2】:

    道歉,这不是答案!我是 StackOverflow 的新手,没有足够的声誉来评论其他答案。如果新手有任何更好的方式要求澄清特定答案,请随时告诉我。

    克莱尔,我面临着和你一样的问题。

    我已将 RAILS_MASTER_KEY 添加到 GitHub actions secret,并更新了我们的 YAML 工作流程:

    env:  
      RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
    

    jobs/test 范围内,以及失败的特定步骤的范围内。

    但是,Rails 初始化始终失败,并显示以下日志:

    An error occurred while loading ./spec/controllers/[name of the controller spec].
    Failure/Error: require File.expand_path("../../config/environment", __FILE__)
    
    NoMethodError:
      undefined method `[]' for nil:NilClass
    

    你怎么能解决这个问题呢? 您是否使用了正确的密钥?

    谢谢你!

    【讨论】:

      猜你喜欢
      • 2018-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-20
      • 2021-03-18
      • 1970-01-01
      相关资源
      最近更新 更多