From c3025e2dfacf610addcf725c113635a17895ecc2 Mon Sep 17 00:00:00 2001 From: Jacob Lauritzen Date: Sat, 26 Sep 2020 14:13:48 +0200 Subject: [PATCH] Get head branch from PRs --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3c26c57..a591ca5 100644 --- a/index.js +++ b/index.js @@ -39,9 +39,12 @@ Toolkit.run(async tools => { await tools.runInWorkspace('git', ['config', 'user.name', `"${process.env.GITHUB_USER || 'Automated Version Bump'}"`]) await tools.runInWorkspace('git', ['config', 'user.email', `"${process.env.GITHUB_EMAIL || 'gh-action-bump-version@users.noreply.github.com'}"`]) - const currentBranch = /refs\/[a-zA-Z]+\/(.*)/.exec(process.env.GITHUB_REF)[1] + let currentBranch = /refs\/[a-zA-Z]+\/(.*)/.exec(process.env.GITHUB_REF)[1] + if (process.env.GITHUB_HEAD_REF) { + console.log('Is pull request'); + currentBranch = process.env.GITHUB_HEAD_REF; + } console.log('currentBranch:', currentBranch) - // do it in the current checked out github branch (DETACHED HEAD) // important for further usage of the package.json version await tools.runInWorkspace('npm',