diff --git a/index.js b/index.js index 2f5bee2..62b67b7 100644 --- a/index.js +++ b/index.js @@ -63,6 +63,25 @@ const createProcfile = ({ procfile, appdir }) => { } }; +const getBranchViaRegex = (branch) => { + if (!branch) return branch; + + try { + let branchName = execSync( + 'git branch -a | grep -m 1 "' + branch + '"' + ).toString(); + + if (!!branchName) { + branchName = branchName.replace('*', '').trim(); + return branchName; + } + } catch(e) { + console.error('No branch found'); + } + + return branch; +} + const deploy = ({ dontuseforce, app_name, @@ -72,6 +91,7 @@ const deploy = ({ dockerBuildArgs, appdir, }) => { + branch = getBranchViaRegex(branch); const force = !dontuseforce ? "--force" : ""; if (usedocker) { execSync(