Merge pull request #39 from Jacse/master

Support running in pull requests
This commit is contained in:
Phil 2020-09-30 15:12:47 +02:00 committed by GitHub
commit baf9e691f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -40,9 +40,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.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'}"`]) 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) {
// Comes from a pull request
currentBranch = process.env.GITHUB_HEAD_REF;
}
console.log('currentBranch:', currentBranch) console.log('currentBranch:', currentBranch)
// do it in the current checked out github branch (DETACHED HEAD) // do it in the current checked out github branch (DETACHED HEAD)
// important for further usage of the package.json version // important for further usage of the package.json version
await tools.runInWorkspace('npm', await tools.runInWorkspace('npm',
@ -52,6 +55,8 @@ Toolkit.run(async tools => {
await tools.runInWorkspace('git', ['commit', '-a', '-m', `ci: ${commitMessage} ${newVersion}`]) await tools.runInWorkspace('git', ['commit', '-a', '-m', `ci: ${commitMessage} ${newVersion}`])
// now go to the actual branch to perform the same versioning // now go to the actual branch to perform the same versioning
// First fetch to get updated local version of branch
await tools.runInWorkspace('git', ['fetch'])
await tools.runInWorkspace('git', ['checkout', currentBranch]) await tools.runInWorkspace('git', ['checkout', currentBranch])
await tools.runInWorkspace('npm', await tools.runInWorkspace('npm',
['version', '--allow-same-version=true', '--git-tag-version=false', current]) ['version', '--allow-same-version=true', '--git-tag-version=false', current])