I am trying to automate build process of android app, I have stored baseUrl in local.properties file, and passing file content through Github secret, but Github action is keep failing,
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
How i am passing BASEURL through Github secret
This is log output from Github action Console
I solved my problem, I was passing wrongly argument from Github secret, it should be like
\"http://fakeapi.com"\
and also i was doing wrong in action file, instead of ./gradlew build it should be
./gradlew assembleDebug --stacktrace
then only it will invoke below part from build.gradle and replace the BaseUrl with new value from local.properties
debug {
buildConfigField 'String', "BASEURL", baseUrl
resValue 'string', "base_url", baseUrl
}
I also used https://github.com/juliangruber/read-file-action to see the content of the local.properties and verified everything is fine in this file or not.