gh-action-bump-version icon indicating copy to clipboard operation
gh-action-bump-version copied to clipboard

Couldn't find any commits in this event [...]

Open migbash opened this issue 2 years ago • 7 comments

Having an issue of:

Couldn't find any commits in this event, incrementing patch version...
tagPrefix: v
tagSuffix: 
commit messages: []

when trying to run an action on:

on:
  pull_request:
    types:
      - closed
    branches:
      - main
 
jobs:
  build:
    if: github.event.pull_request.merged == true
    [....]

Is there a reason it is not detecting the event / commit ?

migbash avatar Mar 16 '23 15:03 migbash

Hi, do I understand this correctly: you want to run the action when you merge your PR? If so, whats your merge strategy? And does it generate a commit? (Merge, squash)

phips28 avatar Mar 17 '23 11:03 phips28

Hi @phips28,

Yes, that's exactly what I mean.

If so, whats your merge strategy?

Using squash merge, which is closed with a squash merge commit.

migbash avatar Mar 17 '23 16:03 migbash

Hmm. There are no commit messages in your logs. can you try push instead of pull_request action on your main branch? Just for testing? But other than that I cant really help here. Never had this setup you have.

phips28 avatar Mar 17 '23 17:03 phips28

i have the same problem when using this action with pull_request [opened], any chance to fix this (or introduce this functionality)?

Goal would be to bump the version when a PR to main is created.

current workflow:

name: Auto-bump version on PR

on:
  pull_request:
    types: [opened]
    branches:
      - main

jobs:
  bump-version:
    permissions:
      contents: write
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          token: ${{ secrets.AUTO_BUMP }}

      - name: "Automated Version Bump"
        uses: "phips28/gh-action-bump-version@master"
        env:
          GITHUB_USER: "xxx"
          GITHUB_EMAIL: "xxx"
          GITHUB_TOKEN: ${{ secrets.AUTO_BUMP }}
        with:
          default: patch
          skip-tag: "true"
          commit-message: 'CI: bump version to {{version}} [skip ci]'
          minor-wording: "#minor"
          major-wording: "#major"
          patch-wording: "#patch"

Barokai avatar Mar 20 '23 06:03 Barokai

I am happy if you provide a PR for that functionality🙂 Currently I am too busy to work on that feature

phips28 avatar Mar 20 '23 07:03 phips28

Hi all, just a quick comment as I have come across the same issue. The action will only work for the push trigger as the code is looking for the commits property on the GITHUB_EVENT_PATH env which contains the payload for the event that triggered the workflow.

If you look at the PR payload https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request the commits property doesn't exists and therefore that's why the action can't find any commits.

I think the best way to improve this is to check the event type and if its not a push then make an api call to get the commits for the triggering branch. This could theoretically work for all other event types too.

darryl-alcumus avatar Mar 31 '23 11:03 darryl-alcumus

Thanks @darryl-alcumus ! this is really helped! I was suffered with same issue. my version plan is "bump the version when PR to main is closed" but never triggered with version wording.

Now I changed events from pull_request to push. anyway, push event also happens after PR was closed and merged.

SpookyJelly avatar Jun 19 '23 05:06 SpookyJelly