Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package io.github.typesafegithub.workflows.shared.internal

import io.github.oshai.kotlinlogging.KotlinLogging.logger
import kotlinx.coroutines.runBlocking

private val logger = logger { }

/**
* Returns a token that should be used to make authorized calls to GitHub,
* or null if no token was configured.
Expand All @@ -10,13 +13,10 @@ import kotlinx.coroutines.runBlocking
*/
fun getGithubAuthTokenOrNull(): String? =
runBlocking {
(System.getenv("GITHUB_TOKEN") ?: getInstallationAccessToken())
.also {
if (it == null) {
println(ERROR_NO_CONFIGURATION)
Comment thread
krzema12 marked this conversation as resolved.
}
}
}
runCatching { getInstallationAccessToken() }
.onFailure { logger.warn(it) { "Failed to get GitHub App Installation token, falling back to GITHUB_TOKEN." } }
.getOrNull() ?: System.getenv("GITHUB_TOKEN")
}.also { if (it == null) logger.warn { ERROR_NO_CONFIGURATION } }

/**
* Returns a token that should be used to make authorized calls to GitHub,
Expand Down
Loading