Skip to content

Commit

Permalink
remove properties action
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Dec 5, 2023
1 parent 3374407 commit e0000de
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 20 deletions.
26 changes: 7 additions & 19 deletions .github/workflows/win-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,14 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Create empty Properties
run: cd . > sekret.properties
working-directory: ${{ github.workspace }}

- name: Create Sekrets
uses: christian-draeger/[email protected]
with:
file_path: ${{ github.workspace }}/sekret.properties
property: |
MONGO_APPLICATION
WRAP_API
FIREBASE_PROJECT
FIREBASE_APPLICATION
FIREBASE_API_KEY
value: |
${{ secrets.MONGO_APPLICATION }}
${{ secrets.WRAP_API }}
${{ secrets.FIREBASE_PROJECT }}
${{ secrets.FIREBASE_APPLICATION }}
${{ secrets.FIREBASE_API_KEY }}
run: |
gradle createSekretProperties -Pkey=MONGO_APPLICATION -Pvalue=${{ secrets.MONGO_APPLICATION }};
gradle createSekretProperties -Pkey=WRAP_API -Pvalue=${{ secrets.WRAP_API }};
gradle createSekretProperties -Pkey=FIREBASE_PROJECT -Pvalue=${{ secrets.FIREBASE_PROJECT }};
gradle createSekretProperties -Pkey=FIREBASE_APPLICATION -Pvalue=${{ secrets.FIREBASE_APPLICATION }};
gradle createSekretProperties -Pkey=FIREBASE_API_KEY -Pvalue=${{ secrets.FIREBASE_API_KEY }}
working-directory: ${{ github.workspace }}

- name: Generate Sekrets
run: gradle generateSekret
Expand Down
39 changes: 38 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain
import java.nio.file.Files

plugins {
alias(libs.plugins.android) apply false
Expand Down Expand Up @@ -138,4 +139,40 @@ fun isNonStable(version: String): Boolean {
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
}

tasks.create("createSekretProperties") {
var file = File(rootDir, "sekret.properties")
val key = properties["key"] as? String ?: return@create
val value = properties["value"] as? String ?: return@create

val append = if (!file.existsSafely()) {
file = file.create()
false
} else {
true
}

if (append) {
file.appendText(
"\n$key=$value"
)
} else {
file.writeText(
"$key=$value"
)
}
}

fun File.existsSafely() = runCatching {
Files.exists(this.toPath())
}.getOrNull() ?: runCatching {
this.exists()
}.getOrNull() ?: false

fun File.create() = runCatching {
Files.createFile(this.toPath()).toFile()
}.getOrNull() ?: runCatching {
this.createNewFile()
this
}.getOrNull() ?: this

0 comments on commit e0000de

Please sign in to comment.