diff options
author | Joffrey Bion <joffrey.bion@gmail.com> | 2022-07-03 18:03:13 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@gmail.com> | 2022-07-03 18:03:58 +0200 |
commit | 1a31505c96a7abced1b680e60beb8abb44fd2b27 (patch) | |
tree | eabe408537dc0ae346a0c41a6ca21173560140d6 /settings.gradle.kts | |
parent | Run CI on all branches (diff) | |
download | seven-wonders-1a31505c96a7abced1b680e60beb8abb44fd2b27.tar.gz seven-wonders-1a31505c96a7abced1b680e60beb8abb44fd2b27.tar.bz2 seven-wonders-1a31505c96a7abced1b680e60beb8abb44fd2b27.zip |
Enable build scans on every CI build
Diffstat (limited to 'settings.gradle.kts')
-rw-r--r-- | settings.gradle.kts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/settings.gradle.kts b/settings.gradle.kts index 21c233fe..344c1f4c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,9 @@ +import com.gradle.scan.plugin.BuildScanExtension + +plugins { + id("com.gradle.enterprise") version "3.10.2" +} + rootProject.name = "seven-wonders" include("sw-common-model") @@ -9,3 +15,36 @@ include("sw-bot") enableFeaturePreview("VERSION_CATALOGS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + +gradleEnterprise { + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + + val isCIBuild = !System.getenv("CI").isNullOrEmpty() + publishAlwaysIf(isCIBuild) + tag(if (isCIBuild) "CI" else "local") + + val isGithubActionsBuild = !System.getenv("GITHUB_ACTIONS").isNullOrEmpty() + if (isGithubActionsBuild) { + addGithubActionsData() + } + } +} + +fun BuildScanExtension.addGithubActionsData() { + value("GitHub Event", System.getenv("GITHUB_EVENT_NAME")) + value("GitHub Workflow", System.getenv("GITHUB_WORKFLOW")) + value("GitHub Run ID", System.getenv("GITHUB_RUN_ID")) + value("GitHub Run number", System.getenv("GITHUB_RUN_NUMBER")) + value("Commit", System.getenv("GITHUB_SHA")) + + val ref = System.getenv("GITHUB_REF") ?: "" + val isTagBuild = ref.startsWith("refs/tags/") + if (isTagBuild) { + tag("tag") + value("Tag", ref.removePrefix("refs/tags/")) + } else { + value("Branch", ref.removePrefix("refs/heads/")) + } +} |