remove ios submodule for now

This commit is contained in:
shabinder 2021-05-19 01:01:09 +05:30
parent 17ea75d007
commit fa11d3e253
8 changed files with 41 additions and 41 deletions

View File

@ -13,7 +13,8 @@ repositories {
}
application {
mainClassName = "MainKt"
mainClass.set("MainKt")
applicationName = "maintenance"
}
dependencies {

View File

@ -2,16 +2,27 @@
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 {
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 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"
}
internal val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(
Json {
ignoreUnknownKeys = true
isLenient = true
}
)
}
}
internal data class GithubFileContent(
val decryptedContent: String,
val sha: String

View File

@ -1,8 +1,5 @@
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.header
import io.ktor.client.request.headers
@ -17,17 +14,6 @@ import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.jsonPrimitive
import kotlinx.serialization.json.put
internal val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(
Json {
ignoreUnknownKeys = true
isLenient = true
}
)
}
}
internal object GithubService {
private const val baseURL = Common.GITHUB_API

View File

@ -12,9 +12,9 @@ internal data class Secrets(
val imageDescription: String,
val commitMessage: String,
val tagName: String
)
internal fun initSecrets() = Secrets(
) {
companion object {
fun initSecrets() = Secrets(
githubToken = "GH_TOKEN".byProperty,
ownerName = "OWNER_NAME".byProperty,
repoName = "REPO_NAME".byProperty,
@ -25,3 +25,5 @@ internal fun initSecrets() = Secrets(
tagName = "TAG_NAME".byOptionalProperty ?: "HTI"
// hctiKey = "HCTI_KEY".analytics_html_img.getByProperty
)
}
}

View File

@ -4,18 +4,18 @@ import kotlinx.coroutines.runBlocking
import utils.debug
internal fun updateAnalyticsImage() {
val secrets = initSecrets()
val secrets = Secrets.initSecrets()
// debug("fun main: secrets -> $secrets")
runBlocking {
val oldGithubFile = GithubService.getGithubFileContent(
token = Common.GH_TOKEN,
token = secrets.githubToken,
ownerName = secrets.ownerName,
repoName = secrets.repoName,
branchName = secrets.branchName,
fileName = "README.md"
)
debug("OLD FILE CONTENT:\n$oldGithubFile")
// debug("OLD FILE CONTENT",oldGithubFile)
/*
* 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",
delayInMilliSeconds = 5000
)
debug("Updated IMAGE:\n$imageURL")
debug("Updated IMAGE", imageURL)
val replacementText = """
${Common.START_SECTION(secrets.tagName)}
![Today's Analytics]($imageURL)
${Common.END_SECTION(secrets.tagName)}
""".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 updatedContent = regex.replace(
oldGithubFile.decryptedContent,
replacementText
)
// debug("Updated File Content:\n$updatedContent")
// debug("Updated File Content",updatedContent)
val updationResponse = GithubService.updateGithubFileContent(
token = Common.GH_TOKEN,
token = secrets.githubToken,
ownerName = secrets.ownerName,
repoName = secrets.repoName,
branchName = secrets.branchName,
@ -53,6 +53,6 @@ internal fun updateAnalyticsImage() {
sha = oldGithubFile.sha
)
debug("File Updation Response:\n$updationResponse")
debug("File Updation Response", updationResponse.toString())
}
}

View File

@ -4,6 +4,6 @@ import utils.debug
fun main(args: Array<String>) {
debug("fun main: args -> ${args.joinToString(";")}")
// Update Analytics Image in Readme
// TASK -> Update Analytics Image in Readme
updateAnalyticsImage()
}

View File

@ -6,3 +6,4 @@ val String.byProperty: String get() = System.getenv(this)
val String.byOptionalProperty: String? get() = System.getenv(this)
fun debug(message: String) = println("::debug::$message")
fun debug(tag: String, message: String) = println("::debug::$tag:\n$message")

@ -1 +0,0 @@
Subproject commit 30c16869ebc81aace8a21cc0ecb0f0314f72b0bc