Last active
December 26, 2018 08:12
-
-
Save JacquesSmuts/217c77ec0e4d8ec8409ae45c3516ec07 to your computer and use it in GitHub Desktop.
Deploying to track based on Git Branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Deployment | |
play { | |
track = getDeploymentTrack() | |
serviceAccountCredentials = file(System.getenv("PRIVATE_KEY") ?: "deployment_private_key.json") | |
defaultToAppBundles = true | |
resolutionStrategy = "ignore" | |
} | |
// The deployment track is based on the branch. | |
static def getDeploymentTrack() { | |
def branch = gitBranch() | |
def track = 'internal' | |
if (branch.equals("master")) { | |
track = "beta" | |
} else if (branch.equals("release")) { | |
track = "alpha" | |
} | |
println("DEPLOYMENT TRACK: " + track) | |
return track | |
} | |
static def gitBranch() { | |
def branch = "" | |
def proc = "git rev-parse --abbrev-ref HEAD".execute() | |
proc.in.eachLine { line -> branch = line } | |
proc.err.eachLine { line -> println line } | |
proc.waitFor() | |
println("BRANCH: " + branch) | |
branch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment