phips28 / gh-action-bump-version

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

Git error error when running the action #206

Closed FernandoArteaga closed 1 year ago

FernandoArteaga commented 1 year ago

Error

When the workflow is run I always get the same error:

Run phips28/gh-action-bump-version@master
  with:
    commit-message: CI: bumps version to {{version}} [skip ci]
    target-branch: main
    major-wording: major:,MAJOR:,bc:,breaking-change:
    minor-wording: minor:,MINOR:,feat:
    rc-wording: pre-alpha,pre-beta,pre-rc
    skip-tag: false
    skip-commit: false
    skip-push: false
    default: patch
    preid: rc
    bump-policy: all
    push: true
  env:
    GITHUB_TOKEN: ***
process.env.GITHUB_WORKSPACE /home/runner/work/doodo-web-ui/doodo-web-ui
tagPrefix: 
tagSuffix: 
commit messages: [ 'change action tag\nundefined' ]
config words: {
  majorWords: [ 'major:', 'MAJOR:', 'bc:', 'breaking-change:' ],
  minorWords: [ 'minor:', 'MINOR:', 'feat:' ],
  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"'
]
currentBranch: main
runInWorkspace | command: npm args: [
  'version',
  '--allow-same-version=true',
  '--git-tag-version=false',
  '0.0.1'
]
current 1: 0.0.1 / version: patch
newVersion 1: 0.0.2
runInWorkspace | command: git args: [ 'commit', '-a', '-m', 'CI: bumps version to 0.0.2 [skip ci]' ]
runInWorkspace | command: git args: [ 'checkout', 'main' ]
✖  fatal     error: pathspec 'main' did not match any file(s) known to git

git exited with code 1
✖  fatal     Failed to bump version

Configuration

This is my current workflow, I just followed your README file.

name: Project versioning
on:
  push:
    branches:
      - "main"
jobs:
  bump_version:
    name: "Bump version"
    permissions:
      contents: write
    runs-on: ubuntu-latest
    steps:
      - uses: "actions/checkout@v3"
        with:
          ref: ${{ github.sha }}
      - name: "Automated version bump"
        uses: "phips28/gh-action-bump-version@master"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          commit-message: 'CI: bumps version to {{version}} [skip ci]'
          target-branch: 'main'
          major-wording:  'major:,MAJOR:,bc:,breaking-change:'
          minor-wording:  'minor:,MINOR:,feat:'
sgalanb commented 1 year ago

Exploring how to get this action working, I tried using pretty much the same code as you. I ended up with the same error. Luckily, comparing it with another example code, I figured out that the ref line is causing this error. To fix it change the .sha with .ref. Hope this helps.

Working code:

name: 'Bump Version'

on:
  push:
    branches:
      - 'main'

jobs:
  bump-version:
    name: 'Bump version on main'
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - name: 'Checkout source code'
        uses: 'actions/checkout@v3'
        with:
          ref: ${{ github.ref }}
      - name: 'cat package.json'
        run: cat ./package.json
      - name: 'Automated Version Bump'
        id: version-bump
        uses: 'phips28/gh-action-bump-version@master'
        with:
          tag-prefix: 'v'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: 'cat package.json'
        run: cat ./package.json
      - name: 'Output Step'
        env:
          NEW_TAG: ${{ steps.version-bump.outputs.newTag }}
        run: echo "new tag $NEW_TAG"
phips28 commented 1 year ago

Correct, as its configured here: https://github.com/phips28/gh-action-bump-version/blob/25cd8ffb8ec95f16f83a8dac9557a845e4fa9e21/.github/workflows/push.yml#L17