From addb49daedf12c79116b2c22836aecbe4d1ee5ed Mon Sep 17 00:00:00 2001 From: lucienshema Date: Thu, 14 Nov 2024 11:35:56 +0200 Subject: [PATCH] added github scret variables --- .github/workflows/android.yml | 22 ++++++++-------------- app/build.gradle | 6 ++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index e2b0a6b..d531670 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,10 +1,7 @@ name: Android CI env: - # Main module of the project main_project_module: app - - # Developer's name dev_name: Lucien Shema on: @@ -12,8 +9,6 @@ on: branches: - main - dev - - # Allows manual workflow runs from the Actions tab workflow_dispatch: jobs: @@ -37,7 +32,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - distribution: 'adopt' # Available distributions can be found in the action's documentation + distribution: 'adopt' java-version: '21.0.4+7.0.LTS' # Set up Gradle with caching for dependencies @@ -47,6 +42,12 @@ jobs: gradle-version: 8.10.2 distribution-url: "https://services.gradle.org/distributions/gradle-8.10.2-bin.zip" + # Inject secrets as environment variables + - name: Inject secret variables + run: | + echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" >> $GITHUB_ENV + echo "BASE_URL=${{ secrets.BASE_URL }}" >> $GITHUB_ENV + # Change Gradle wrapper permissions - name: Change Gradle wrapper permissions run: chmod +x ./gradlew @@ -59,14 +60,6 @@ jobs: ./gradlew wrapper fi - - name: Download gradle-wrapper.jar if missing - run: | - if [ ! -f ./gradle/wrapper/gradle-wrapper.jar ]; then - mkdir -p ./gradle/wrapper - curl -L -o ./gradle/wrapper/gradle-wrapper.jar https://services.gradle.org/distributions/gradle-wrapper-8.10.2.jar - fi - - # Build the project - name: Build Gradle project run: ./gradlew build @@ -79,6 +72,7 @@ jobs: + # # Create APK Debug # - name: Build apk debug project (APK)-${{ env.main_project_module }} module # run: ./gradlew assembleDebug diff --git a/app/build.gradle b/app/build.gradle index c9c8f53..396dd5d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,6 +7,10 @@ plugins { id 'kotlin-parcelize' } + +def googleMapsApiKey = System.getenv("GOOGLE_MAPS_API_KEY") ?: "" +def baseUrl = System.getenv("BASE_URL") ?: "" + android { namespace 'org.technoserve.farmcollector' compileSdk 34 @@ -21,6 +25,8 @@ android { vectorDrawables { useSupportLibrary true } + buildConfigField "String", "GOOGLE_MAPS_API_KEY", "\"${googleMapsApiKey}\"" + buildConfigField "String", "BASE_URL", "\"${baseUrl}\"" } buildTypes {