【问题标题】:How to run `./gradlew test` using GitHub Actions in a repository that does not have keystore file uploaded?如何在没有上传密钥库文件的存储库中使用 GitHub Actions 运行`./gradlew test`?
【发布时间】:2021-01-29 11:25:12
【问题描述】:

我有一个没有提交 /keystores/keystore.properties 的存储库。当我在 GitHub Actions 中运行 ./gradlew test 命令并尝试构建我的 gradle 文件时,一旦它到达关于为发布构建创建签名配置的行,它就会失败并出现以下错误:

/keystores/keystore.properties (No such file or directory)

是否可以创建一个临时的keystore.properties文件并在任务执行后将其删除?

【问题讨论】:

    标签: android unit-testing gradle github-actions android-keystore


    【解决方案1】:

    好吧,当您不想推送该文件时,GitHub Actions 无法获取该文件。但是,您可以改用Encrypted Secrets:

    1. 将 keystore.properties 文件的内容放入Encrypted Secret。将其命名为KEYSTORE_PROPERTIES。

    2. 在您的 ./gradlew test 步骤之前添加一个步骤,将内容写入本地 keystore.properties 文件:

      # …
      steps:
        # …
        - run: echo ${{ secrets.KEYSTORE_PROPERTIES }} >> keystore.properties
        - run: ./gradlew test
        # …
      
    3. 构建应该可以工作。

    请注意,GitHub Actions 不会在日志中输出机密信息,而只会输出星号,但 echo 仍然可以将数据放入文件中。

    【讨论】:

      猜你喜欢
      • 2020-05-31
      • 2012-04-04
      • 2020-07-10
      • 2021-09-16
      • 2021-09-07
      • 2019-10-20
      • 2021-03-11
      • 2021-10-07
      • 1970-01-01
      相关资源
      最近更新 更多