我正在尝试自动化 Android 应用程序的构建过程,我已将 baseUrl 存储在 local.properties 文件中,并通过 Github 秘密传递文件内容,但 Github 操作一直失败,
构建.gradle:
def propFile=rootProject.file("./local.properties")
def properties = new Properties()
properties.load(new FileInputStream(propFile))
def baseUrl = properties['BASEURL']
//getProperty("BASEURL", "")
debug {
buildConfigField 'String', "BASEURL", baseUrl
resValue 'string', "base_url", baseUrl
}
YML:
name: Android CI
on:
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Decode BASEURL
env:
BASEURL: ${{ secrets.BASEURL }}
run: echo BASEURL="$BASEURL" > ./local.properties
- name: Clean
run: ./gradlew clean
- name: Build with Gradle
run: ./gradlew build
我如何通过 Github 秘密传递 BASEURL
这是 Github 操作控制台的日志输出
我解决了我的问题,我从 Github 秘密传递了错误的参数,它应该像
\"http://fakeapi.com"\
而且我在操作文件中做错了,而不是 ./gradlew build 它应该是
./gradlew assembleDebug --stacktrace
那么只有它会调用 build.gradle 中的以下部分,并将 BaseUrl 替换为 local.properties 中的新值
debug {
buildConfigField 'String', "BASEURL", baseUrl
resValue 'string', "base_url", baseUrl
}
我也用过https://github.com/juliangruber/read-file-action https://github.com/juliangruber/read-file-action查看 local.properties 的内容并验证此文件中的一切是否正常。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)