thehanimo / pr-title-checker

An action to automatically check if pull request titles conform to Contribution Guidelines
MIT License
106 stars 36 forks source link

After title error and once properly formatted, title checker doesn't re-run and pass. #7

Closed davidsteelebrady closed 2 years ago

davidsteelebrady commented 2 years ago

Hi there,

Potentially not understanding usage properly here but to replicate.

  1. Using
    
    name: PR Title check
    runs-on: ubuntu-latest
    steps:
      - uses: thehanimo/pr-title-checker@v1.2
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2. Create a PR with a poorly formatted title.
3. Title checker correctly identifies issue with title.  
![image](https://user-images.githubusercontent.com/76475855/138262830-b761fc6b-aabf-4198-9b6d-fc378073baad.png)
4. Fix title to pass Regex
5. Pipeline does **NOT** automatically re-run title checker. 

Is there a way to re-run the title checker without having to add to the PR? 
thehanimo commented 2 years ago

Hi! Can you make sure your yaml file looks something like this:

name: "PR Title Checker"
on:
  pull_request:
    types:
      - opened
      - edited
      - synchronize
      - labeled
      - unlabeled

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: thehanimo/pr-title-checker@v1.3.1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The types under on: pull_request: is what you're missing. In your case of re-naming the title, I think edited is the one you're missing.

davidsteelebrady commented 2 years ago

Hi @thehanimo Thanks for the quick response. I realised that the code example I added wasn't complete. We are testing for PR but not types. Thanks for the hint. Will report back.

jobs:
  check:
    if: ${{ github.event_name == 'pull_request' }}
    name: PR Title check
    runs-on: ubuntu-latest
    steps:
      - uses: thehanimo/pr-title-checker@v1.2
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

It does make me wonder what the default associated types are that would mean it doesn't fire.

thehanimo commented 2 years ago

From the docs,

By default, a workflow only runs when a pull_request's activity type is opened, synchronize, or reopened. To trigger workflows for more activity types, use the types keyword.

davidsteelebrady commented 2 years ago

@thehanimo Yeah I had Edit in place, it turned out to be labelled/unlabeled that resolves it, which makes sense as a label is applied when broken. Thanks for your help, closing now.

Good action!

thehanimo commented 2 years ago

@davidsteelebrady I'm glad that helped! But I don't seem to understand why labelled/unlabelled helped? Afaik, in your case, a poorly formatted PR Title was labelled by the action. This title was then "edited" by the user right? Are you sure edited is not what you're looking for?

Also, triggering this on labelled/unlabelled seems redundant. For e.g, a poorly formatted title would initially trigger the action which in turn, labels the PR. This "labelling of the PR" then triggers another redundant check? Is there something I'm missing?