mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-22 17:14:32 +01:00
remove ios submodule for now
This commit is contained in:
parent
17ea75d007
commit
fa11d3e253
@ -13,7 +13,8 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClassName = "MainKt"
|
mainClass.set("MainKt")
|
||||||
|
applicationName = "maintenance"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -2,16 +2,27 @@
|
|||||||
|
|
||||||
package analytics_html_img
|
package analytics_html_img
|
||||||
|
|
||||||
import utils.byProperty
|
import io.ktor.client.HttpClient
|
||||||
|
import io.ktor.client.features.json.JsonFeature
|
||||||
|
import io.ktor.client.features.json.serializer.KotlinxSerializer
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
internal object Common {
|
internal object Common {
|
||||||
const val GITHUB_API = "https://api.github.com"
|
const val GITHUB_API = "https://api.github.com"
|
||||||
val GH_TOKEN get() = "GH_TOKEN".byProperty
|
|
||||||
fun START_SECTION(tagName: String = "HTI") = "<!--START_SECTION:$tagName-->"
|
fun START_SECTION(tagName: String = "HTI") = "<!--START_SECTION:$tagName-->"
|
||||||
fun END_SECTION(tagName: String = "HTI") = "<!--END_SECTION:$tagName-->"
|
fun END_SECTION(tagName: String = "HTI") = "<!--END_SECTION:$tagName-->"
|
||||||
const val USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0"
|
const val USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0"
|
||||||
}
|
}
|
||||||
|
internal val client = HttpClient {
|
||||||
|
install(JsonFeature) {
|
||||||
|
serializer = KotlinxSerializer(
|
||||||
|
Json {
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
isLenient = true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
internal data class GithubFileContent(
|
internal data class GithubFileContent(
|
||||||
val decryptedContent: String,
|
val decryptedContent: String,
|
||||||
val sha: String
|
val sha: String
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package analytics_html_img
|
package analytics_html_img
|
||||||
|
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.features.json.JsonFeature
|
|
||||||
import io.ktor.client.features.json.serializer.KotlinxSerializer
|
|
||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import io.ktor.client.request.header
|
import io.ktor.client.request.header
|
||||||
import io.ktor.client.request.headers
|
import io.ktor.client.request.headers
|
||||||
@ -17,17 +14,6 @@ import kotlinx.serialization.json.buildJsonObject
|
|||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
import kotlinx.serialization.json.put
|
import kotlinx.serialization.json.put
|
||||||
|
|
||||||
internal val client = HttpClient {
|
|
||||||
install(JsonFeature) {
|
|
||||||
serializer = KotlinxSerializer(
|
|
||||||
Json {
|
|
||||||
ignoreUnknownKeys = true
|
|
||||||
isLenient = true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal object GithubService {
|
internal object GithubService {
|
||||||
private const val baseURL = Common.GITHUB_API
|
private const val baseURL = Common.GITHUB_API
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ internal data class Secrets(
|
|||||||
val imageDescription: String,
|
val imageDescription: String,
|
||||||
val commitMessage: String,
|
val commitMessage: String,
|
||||||
val tagName: String
|
val tagName: String
|
||||||
)
|
) {
|
||||||
|
companion object {
|
||||||
internal fun initSecrets() = Secrets(
|
fun initSecrets() = Secrets(
|
||||||
githubToken = "GH_TOKEN".byProperty,
|
githubToken = "GH_TOKEN".byProperty,
|
||||||
ownerName = "OWNER_NAME".byProperty,
|
ownerName = "OWNER_NAME".byProperty,
|
||||||
repoName = "REPO_NAME".byProperty,
|
repoName = "REPO_NAME".byProperty,
|
||||||
@ -25,3 +25,5 @@ internal fun initSecrets() = Secrets(
|
|||||||
tagName = "TAG_NAME".byOptionalProperty ?: "HTI"
|
tagName = "TAG_NAME".byOptionalProperty ?: "HTI"
|
||||||
// hctiKey = "HCTI_KEY".analytics_html_img.getByProperty
|
// hctiKey = "HCTI_KEY".analytics_html_img.getByProperty
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,18 +4,18 @@ import kotlinx.coroutines.runBlocking
|
|||||||
import utils.debug
|
import utils.debug
|
||||||
|
|
||||||
internal fun updateAnalyticsImage() {
|
internal fun updateAnalyticsImage() {
|
||||||
val secrets = initSecrets()
|
val secrets = Secrets.initSecrets()
|
||||||
// debug("fun main: secrets -> $secrets")
|
// debug("fun main: secrets -> $secrets")
|
||||||
|
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val oldGithubFile = GithubService.getGithubFileContent(
|
val oldGithubFile = GithubService.getGithubFileContent(
|
||||||
token = Common.GH_TOKEN,
|
token = secrets.githubToken,
|
||||||
ownerName = secrets.ownerName,
|
ownerName = secrets.ownerName,
|
||||||
repoName = secrets.repoName,
|
repoName = secrets.repoName,
|
||||||
branchName = secrets.branchName,
|
branchName = secrets.branchName,
|
||||||
fileName = "README.md"
|
fileName = "README.md"
|
||||||
)
|
)
|
||||||
debug("OLD FILE CONTENT:\n$oldGithubFile")
|
// debug("OLD FILE CONTENT",oldGithubFile)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use Any Random useless query param ,
|
* Use Any Random useless query param ,
|
||||||
@ -26,24 +26,24 @@ internal fun updateAnalyticsImage() {
|
|||||||
url = "https://kind-grasshopper-73.telebit.io/matomo/index.php?module=Widgetize&action=iframe&containerId=VisitOverviewWithGraph&disableLink=0&widget=1&moduleToWidgetize=CoreHome&actionToWidgetize=renderWidgetContainer&idSite=1&period=week&date=today&disableLink=1&widget=$randomID",
|
url = "https://kind-grasshopper-73.telebit.io/matomo/index.php?module=Widgetize&action=iframe&containerId=VisitOverviewWithGraph&disableLink=0&widget=1&moduleToWidgetize=CoreHome&actionToWidgetize=renderWidgetContainer&idSite=1&period=week&date=today&disableLink=1&widget=$randomID",
|
||||||
delayInMilliSeconds = 5000
|
delayInMilliSeconds = 5000
|
||||||
)
|
)
|
||||||
debug("Updated IMAGE:\n$imageURL")
|
debug("Updated IMAGE", imageURL)
|
||||||
|
|
||||||
val replacementText = """
|
val replacementText = """
|
||||||
${Common.START_SECTION(secrets.tagName)}
|
${Common.START_SECTION(secrets.tagName)}
|
||||||
![Today's Analytics]($imageURL)
|
![Today's Analytics]($imageURL)
|
||||||
${Common.END_SECTION(secrets.tagName)}
|
${Common.END_SECTION(secrets.tagName)}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
// debug("Updated Text to be Inserted:\n$replacementText")
|
debug("Updated Text to be Inserted", replacementText)
|
||||||
|
|
||||||
val regex = """${Common.START_SECTION(secrets.tagName)}(?s)(.*)${Common.END_SECTION(secrets.tagName)}""".toRegex()
|
val regex = """${Common.START_SECTION(secrets.tagName)}(?s)(.*)${Common.END_SECTION(secrets.tagName)}""".toRegex()
|
||||||
val updatedContent = regex.replace(
|
val updatedContent = regex.replace(
|
||||||
oldGithubFile.decryptedContent,
|
oldGithubFile.decryptedContent,
|
||||||
replacementText
|
replacementText
|
||||||
)
|
)
|
||||||
// debug("Updated File Content:\n$updatedContent")
|
// debug("Updated File Content",updatedContent)
|
||||||
|
|
||||||
val updationResponse = GithubService.updateGithubFileContent(
|
val updationResponse = GithubService.updateGithubFileContent(
|
||||||
token = Common.GH_TOKEN,
|
token = secrets.githubToken,
|
||||||
ownerName = secrets.ownerName,
|
ownerName = secrets.ownerName,
|
||||||
repoName = secrets.repoName,
|
repoName = secrets.repoName,
|
||||||
branchName = secrets.branchName,
|
branchName = secrets.branchName,
|
||||||
@ -53,6 +53,6 @@ internal fun updateAnalyticsImage() {
|
|||||||
sha = oldGithubFile.sha
|
sha = oldGithubFile.sha
|
||||||
)
|
)
|
||||||
|
|
||||||
debug("File Updation Response:\n$updationResponse")
|
debug("File Updation Response", updationResponse.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,6 @@ import utils.debug
|
|||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
debug("fun main: args -> ${args.joinToString(";")}")
|
debug("fun main: args -> ${args.joinToString(";")}")
|
||||||
|
|
||||||
// Update Analytics Image in Readme
|
// TASK -> Update Analytics Image in Readme
|
||||||
updateAnalyticsImage()
|
updateAnalyticsImage()
|
||||||
}
|
}
|
||||||
|
@ -6,3 +6,4 @@ val String.byProperty: String get() = System.getenv(this)
|
|||||||
val String.byOptionalProperty: String? get() = System.getenv(this)
|
val String.byOptionalProperty: String? get() = System.getenv(this)
|
||||||
|
|
||||||
fun debug(message: String) = println("::debug::$message")
|
fun debug(message: String) = println("::debug::$message")
|
||||||
|
fun debug(tag: String, message: String) = println("::debug::$tag:\n$message")
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 30c16869ebc81aace8a21cc0ecb0f0314f72b0bc
|
|
Loading…
Reference in New Issue
Block a user