From f7da5918770bcd7198a0e6803210f15aebce88b7 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Mon, 13 Dec 2021 16:29:22 +0200 Subject: [PATCH] buildscript: add check for ci environment when adding github maven packages configuration --- build.gradle | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 8511ff2..b6d682e 100644 --- a/build.gradle +++ b/build.gradle @@ -463,18 +463,26 @@ artifacts { // publishing publishing { - repositories { - String owner = System.getenv("REPOSITORY_OWNER") - String repositoryName = System.getenv("REPOSITORY_NAME") - maven { - name = "GitHubPackages" - url = "https://maven.pkg.github.com/$owner/$repositoryName" - credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") - } + repositories { + String owner = System.getenv("REPOSITORY_OWNER") + String repositoryName = System.getenv("REPOSITORY_NAME") + String githubUser = System.getenv("GITHUB_ACTOR") + String githubToken = System.getenv("GITHUB_TOKEN") + boolean isInGithubCIEnvironment = owner != null && repositoryName != null && githubUser != null && githubToken != null + + if (isInGithubCIEnvironment) { + maven { + name = "GitHubPackages" + url = "https://maven.pkg.github.com/$owner/$repositoryName" + credentials { + username = githubUser + password = githubToken + } + } + } else { + print("Assuming not being in CI environment: skipping github publishing configuration") + } } - } } // Updating