gpt4 book ai didi

android - 通过 Git Hub secret 传递 build.gradle android 中的 local.properties

转载 作者:行者123 更新时间:2023-12-04 12:58:42 25 4
gpt4 key购买 nike

我正在尝试自动化 android 应用程序的构建过程,我已将 baseUrl 存储在 local.properties 文件中,并通过 Github secret 传递文件内容,但 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 secret 传递 BASEURL

enter image description here

这是 Github 操作控制台的日志输出

enter image description here

最佳答案

我解决了我的问题,我从 Github secret 传递了错误的论点,应该像

\"http://fakeapi.com"\

而且我在 Action 文件中做错了,而不是 ./gradlew build 它应该是
./gradlew assembleDebug --stacktrace

然后只有它会从 build.gradle 调用下面的部分,并用 local.properties 中的新值替换 BaseUrl
debug {
buildConfigField 'String', "BASEURL", baseUrl
resValue 'string', "base_url", baseUrl
}

我也用过 https://github.com/juliangruber/read-file-action查看 local.properties 的内容并验证此文件中的一切是否正常。

关于android - 通过 Git Hub secret 传递 build.gradle android 中的 local.properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62278936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com