1

我正在使用 Expo 开发一个开源 React Native 应用程序。我有一些不应该提交给 repo 的敏感细节(我的 Sentry 和 Amplitude API 密钥)。我知道我可以将它们保存在config.js文件中并将其添加到我的.gitignore.,但我想通过 CI 保持我的构建(发布)过程自动化(我不想从我的本地机器发布)。我该怎么办?

4

1 回答 1

1
1 > Open GitLab repo of your project.
2 > Now Goto CICD setting and expand the `Variables` property
3 > add 'Input variable key' like `CONFIG_JS` and paste all your content of a config.js file as an 'Input variable value' 
4 > It is secure, So don't worry about security

完成此步骤后,在您的.gitlab-ci.yml文件之前添加以下行android-bundleandroid-release在脚本中添加命令

 - mkdir /Config
 - "echo $CONFIG_JS > /Config/config.js" # replace CONFIG_JS with your variable name that you set in CICD settings

上面的命令 Config在运行时创建一个目录并从变量值创建一个 config.js 文件。您需要做的就是从“配置/配置”文件中导入 config.js 文件

就是这样:)

于 2018-12-05T11:02:16.767 回答