diff --git a/index.js b/index.js index abca913..3b9ceea 100644 --- a/index.js +++ b/index.js @@ -142,13 +142,14 @@ const workspace = process.env.GITHUB_WORKSPACE; `"${process.env.GITHUB_EMAIL || 'gh-action-bump-version@users.noreply.github.com'}"`, ]); - const refsRegExResult = /refs\/[a-zA-Z]+\/(.*)/.exec(process.env.GITHUB_REF); - let currentBranch = refsRegExResult ? refsRegExResult[1] : undefined; + let currentBranch; let isPullRequest = false; if (process.env.GITHUB_HEAD_REF) { // Comes from a pull request currentBranch = process.env.GITHUB_HEAD_REF; isPullRequest = true; + } else { + currentBranch = /refs\/[a-zA-Z]+\/(.*)/.exec(process.env.GITHUB_REF)[1]; } if (process.env['INPUT_TARGET-BRANCH']) { // We want to override the branch that we are pulling / pushing to