@@ -71,15 +71,15 @@ def gitShortRev() {
7171}
7272
7373def setScm (scm ) {
74- scm. appendNode(' connection' , ' https://github.com/Tencent /Shadow.git' )
74+ scm. appendNode(' connection' , " https://github.com/${ System.getenv("GITHUB_ACTOR") } /Shadow.git" )
7575
7676 def commit
77- if (" ${ System.env.ORANGE } " . equalsIgnoreCase(" true" )) {
78- commit = " ${ System.env.ORANGE_COMMIT } "
77+ if (" ${ System.env.CI } " . equalsIgnoreCase(" true" )) {
78+ commit = System . getenv( " GITHUB_SHA " )
7979 } else {
8080 commit = gitShortRev()
8181 }
82- scm. appendNode(' url' , " https://github.com/Tencent /Shadow/commit/$commit " )
82+ scm. appendNode(' url' , " https://github.com/${ System.getenv("GITHUB_ACTOR") } /Shadow/commit/$commit " )
8383}
8484
8585def setGeneratePomFileAndDepends (publicationName ) {
@@ -387,7 +387,40 @@ publishing {
387387 }
388388 }
389389 repositories {
390- mavenLocal()
390+ def useLocalCredential = false
391+ Properties properties = new Properties ()
392+ def propertiesFile = project. rootProject. file(' local.properties' )
393+ if (propertiesFile. exists()) {
394+ properties. load(propertiesFile. newDataInputStream())
395+
396+ if (" ${ properties.getProperty('gpr.local')} " . equalsIgnoreCase(' true' )) {
397+ def user = properties. getProperty(' gpr.user' )
398+ def key = properties. getProperty(' gpr.key' )
399+ maven {
400+ name = " GitHubPackages"
401+ credentials {
402+ username = user
403+ password = key
404+ }
405+ url " https://maven.pkg.github.com/${ user} /shadow"
406+ }
407+
408+ useLocalCredential = true
409+ }
410+ }
411+
412+ if (! useLocalCredential && " ${ System.env.CI} " . equalsIgnoreCase(" true" )) {
413+ maven {
414+ name = " GitHubPackages"
415+ credentials {
416+ username = System . getenv(" GITHUB_ACTOR" )
417+ password = System . getenv(" GITHUB_TOKEN" )
418+ }
419+ url " https://maven.pkg.github.com/" + " ${ System.env.GITHUB_REPOSITORY} " . toLowerCase()
420+ }
421+ } else {
422+ mavenLocal()
423+ }
391424 }
392425}
393426
0 commit comments