我正在尝试自动化构建Android应用程序的过程,我已将baseUrl存储在local.properties文件中,并通过Github secret传递文件内容,但是Github操作一直失败。
build.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 Action 控制台的日志输出
local.properties
放置在项目的根目录下。请尝试执行echo BASEURL="$BASEURL" > ./local.properties
命令,并运行ls -al
命令查看文件布局。 - smac89