phips28 / gh-action-bump-version

GitHub Action for automated npm version bump.
MIT License
336 stars 249 forks source link

Deployment event does not take in the target branch attribute #214

Closed mmatotan closed 1 year ago

mmatotan commented 1 year ago

Getting this error:

Run phips28/gh-action-bump-version@master
process.env.GITHUB_WORKSPACE /home/runner/work/secret/secret
tagPrefix: 
tagSuffix: 
commit messages: []
config words: {
  majorWords: [ 'BREAKING CHANGE', 'major' ],
  minorWords: [ 'feat', 'minor' ],
  patchWords: null,
  preReleaseWords: [ 'pre-alpha', 'pre-beta', 'pre-rc' ]
}
version action after first waterfall: patch
version action after final decision: patch
runInWorkspace | command: git args: [ 'config', 'user.name', '"Automated Version Bump"' ]
runInWorkspace | command: git args: [
  'config',
  'user.email',
  '"gh-action-bump-version@users.noreply.github.com"'
]
✖  fatal     TypeError: Cannot read properties of null (reading '1')
    at /home/runner/work/_actions/phips[28](https://github.com/secret/secret/actions/runs/secret_number/jobs/secret_number#step:3:29)/gh-action-bump-version/master/index.js:182:75
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
✖  fatal     Failed to bump version

If I understand correctly, this line of code fails:

        currentBranch = /refs\/[a-zA-Z]+\/(.*)/.exec(process.env.GITHUB_REF)[1];

And in the case of a deployment event the process.env.GITHUB_REF is null and hence the whole regex throws an error that there is no [1] of null. I will open a PR to optionally select the second element in the array.