2021-06-05 20:43:55 +02:00
|
|
|
import common.GithubService
|
|
|
|
import common.Secrets
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
import scripts.updateAnalyticsImage
|
|
|
|
import scripts.updateDownloadCards
|
2021-05-18 16:57:33 +02:00
|
|
|
import utils.debug
|
|
|
|
|
|
|
|
fun main(args: Array<String>) {
|
|
|
|
debug("fun main: args -> ${args.joinToString(";")}")
|
2021-06-05 20:43:55 +02:00
|
|
|
val secrets = Secrets.initSecrets()
|
2021-05-18 16:57:33 +02:00
|
|
|
|
2021-06-05 20:43:55 +02:00
|
|
|
runBlocking {
|
|
|
|
|
|
|
|
val githubFileContent = GithubService.getGithubFileContent(
|
|
|
|
secrets = secrets,
|
|
|
|
fileName = "README.md"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Content To be Processed
|
|
|
|
var updatedGithubContent: String = githubFileContent.decryptedContent
|
|
|
|
|
|
|
|
// TASK -> Update Analytics Image in Readme
|
2021-06-05 21:02:49 +02:00
|
|
|
try {
|
|
|
|
updatedGithubContent = updateAnalyticsImage(
|
|
|
|
updatedGithubContent,
|
|
|
|
secrets
|
|
|
|
)
|
|
|
|
} catch (e:Exception) {
|
|
|
|
debug("Analytics Image Updation Failed",e.message.toString())
|
|
|
|
}
|
2021-06-05 20:43:55 +02:00
|
|
|
|
|
|
|
// TASK -> Update Total Downloads Card
|
2021-06-05 21:02:49 +02:00
|
|
|
try {
|
|
|
|
updatedGithubContent = updateDownloadCards(
|
|
|
|
updatedGithubContent,
|
|
|
|
secrets.copy(tagName = "DCI")
|
|
|
|
)
|
|
|
|
} catch (e:Exception) {
|
|
|
|
debug("Download Card Updation Failed",e.message.toString())
|
|
|
|
}
|
2021-06-05 20:43:55 +02:00
|
|
|
|
|
|
|
// Write New Updated README.md
|
|
|
|
GithubService.updateGithubFileContent(
|
|
|
|
token = secrets.githubToken,
|
|
|
|
ownerName = secrets.ownerName,
|
|
|
|
repoName = secrets.repoName,
|
|
|
|
branchName = secrets.branchName,
|
|
|
|
fileName = secrets.filePath,
|
|
|
|
commitMessage = secrets.commitMessage,
|
|
|
|
rawContent = updatedGithubContent,
|
|
|
|
sha = githubFileContent.sha
|
|
|
|
)
|
|
|
|
}
|
2021-05-18 16:57:33 +02:00
|
|
|
}
|