在 Github 动作中使用 React-Native Expo 而无需提交 'env' js 文件
Using React-Native Expo in Github Actions without committing 'env' js file
我正在尝试为每次推送 master 构建一个 APK。
但我使用的是 'env' 文件,Expo 需要它来构建 APK(在代码的某些地方导入它)。
我不想提交 'env' 文件,并试图避免它。
是否有任何解决方法,或者我是否必须提交 'env' 文件?
谢谢!
已解决:
我找到了解决办法。我将整个文件保存为 Github Secret,然后添加了一个脚本以从 Secret 创建 env 文件。
- name: Create env.js file
uses: actions/github-script@0.9.0
with:
script: |
const fs = require('fs');
if (!fs.existsSync('env.js')) {
fs.writeFileSync('env.js', process.env.ENV_FILE);
}
env:
ENV_FILE: ${{ secrets.ENV_FILE }}
我正在尝试为每次推送 master 构建一个 APK。 但我使用的是 'env' 文件,Expo 需要它来构建 APK(在代码的某些地方导入它)。 我不想提交 'env' 文件,并试图避免它。
是否有任何解决方法,或者我是否必须提交 'env' 文件?
谢谢!
已解决: 我找到了解决办法。我将整个文件保存为 Github Secret,然后添加了一个脚本以从 Secret 创建 env 文件。
- name: Create env.js file
uses: actions/github-script@0.9.0
with:
script: |
const fs = require('fs');
if (!fs.existsSync('env.js')) {
fs.writeFileSync('env.js', process.env.ENV_FILE);
}
env:
ENV_FILE: ${{ secrets.ENV_FILE }}