Skip to content

Commit 5afd19d

Browse files
authored
Merge pull request #187 from hossain-khan/api-key
[ADDED] Gradle enformecement for missing api key
2 parents 3acdeca + 9963fc6 commit 5afd19d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.github/workflows/android-lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
push:
66
branches: [ "main" ]
77

8+
env:
9+
EMAIL_API_KEY: 'FAKE_KEY_TO_PASS_CI'
10+
811
jobs:
912
android-post-check:
1013

.github/workflows/android.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
pull_request:
77
branches: [ "main" ]
88

9+
env:
10+
EMAIL_API_KEY: 'FAKE_KEY_TO_PASS_CI'
11+
912
jobs:
1013
android-build:
1114
runs-on: ubuntu-latest

app/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ android {
3333
project.rootProject.file("local.properties").takeIf { it.exists() }?.inputStream()?.use {
3434
Properties().apply { load(it) }
3535
}
36-
val apiKey = localProperties?.getProperty("EMAIL_API_KEY") ?: "MISSING-KEY"
36+
val apiKey = System.getenv("EMAIL_API_KEY") ?: localProperties?.getProperty("EMAIL_API_KEY") ?: ""
37+
if (apiKey.isBlank()) {
38+
error("""
39+
EMAIL_API_KEY is not set in `local.properties`
40+
Please add 'EMAIL_API_KEY=your_api_key' to `local.properties` file.
41+
""".trimIndent())
42+
}
3743
buildConfigField("String", "EMAIL_API_KEY", "\"$apiKey\"")
3844

3945
// Git commit hash to identify build source

0 commit comments

Comments
 (0)