2

I have an issue with a GitHub Action, I'm trying to create versioning for an app when doing merge of a PR, but no matter if using npm version <version> or git commit -a -m "message", I'm getting the next error:

error: insufficient permission for adding an object to repository database .git/objects
error: package.json: failed to insert into database
error: unable to index file 'package.json'
fatal: updating files failed
Error: Process completed with exit code 128.

The Git configuration is as usual, and I firstly created a repo to test this workflow, and I didn't have this kind of errors. I'm gonna paste an extract of the workflow:

name: Create Tag
on:
  pull_request:
    branches:
      - dev
    types: [closed]

jobs:
  tag:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the repo
        uses: actions/checkout@v2
        with:
          ref: ${{ github.ref }}
      - name: Cofiguring Git
        run: |-
          git config user.name $GITHUB_ACTOR
          git config user.email gh-actions-${GITHUB_ACTOR}@github.com
      # Bump version on merging Pull Requests with specific labels. (bump:major,bump:minor,bump:patch)
      - name: Version Calculation
        if: github.event.pull_request.merged
        id: version-calc
        uses: haya14busa/action-bumpr@v1
        with:
          dry_run: true
          default_bump_level: patch
      - name: Change version
        uses: reedyuk/npm-version@1.1.1
        with:
          version: ${{ steps.version-calc.outputs.next_version }}
          git-tag-version: 'false'
      - name: Push version
        run: |-
          git commit -a -m "ci(version): level up version"
          git tag ${{ steps.version-calc.outputs.next_version }}
          git push origin ${{ steps.version-calc.outputs.next_version }}

You may also check the testing repo: https://github.com/alfchee/versioning-with-actions

Alfchee
  • 345
  • 1
  • 5
  • 14
  • When you use `with: ref:` in the checkout step, don't you get a detached HEAD? I think you can drop that since it's the default behaviour of checkout, no? – Benjamin W. Jul 29 '21 at 18:12
  • 1
    You can resolve this by [adding a PAT](https://stackoverflow.com/a/58393457/17848671) – Ondřej Tůma Jan 13 '22 at 17:12

0 Answers0