action-semantic-pull-request icon indicating copy to clipboard operation
action-semantic-pull-request copied to clipboard

Validation is leaving empty messages

Open alec-eu opened this issue 3 years ago • 2 comments

I have been using this action for many of my companies projects and really enjoy it! Specifically we have been using the example repo that adds a comment if the message does not comply and removes it if it does. However, the past few days it has begun to leave comments on all PRs, with empty bodies that look like this: Screen Shot 2022-11-01 at 12 30 09 PM Regardless of whether the title matches the spec or not. Has anyone else run into this?

This is my workflow:

jobs:
  Lint-title:
    name: Validate PR title
    runs-on: ubuntu-latest
    steps:
      - uses: amannn/action-semantic-pull-request@v4
        id: lint_pr_title
        with:
          ignoreLabels: |
            bot
            ignore-semantic-pull-request
            dependencies
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - uses: marocchino/sticky-pull-request-comment@v2
        # When the previous steps fails, the workflow would stop. By adding this
        # condition you can continue the execution with the populated error message.
        if: always()
        with:
          header: pr-title-lint-error
          message: |
            Hey there and thank you for opening this pull request! 👋🏼
            We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
            Details:
            ```
            ${{ steps.lint_pr_title.outputs.error_message }}
            ```
      # Delete a previous comment when the issue has been resolved
      - if: ${{ steps.lint_pr_title.outputs.error_message == null }}
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          header: pr-title-lint-error
          delete: true

alec-eu avatar Nov 01 '22 17:11 alec-eu

Hi and thanks for opening the issue! It might be related to a change in the sticky-pull-request-comment action. I saw there was recently an ignore_empty option added: https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.3.0.

Probably this could be fixed by something like if: failure() instead of if: always() in the workflow.

If you figure out a solution, can you share it here? If you care to open a PR that adjusts the docs that would be incredible!

amannn avatar Nov 01 '22 18:11 amannn

This works for me

jobs:
  title:
    name: Validate PR title
    runs-on: ubuntu-latest
    steps:
      - uses: amannn/action-semantic-pull-request@v5
        id: lint_pr_title
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - uses: marocchino/sticky-pull-request-comment@v2
        # When the previous steps fails, the workflow would stop. By adding this
        # condition you can continue the execution with the populated error message.
        if: ${{ always() }}
        with:
          header: ${{ github.job }}
          message: |
            👋 Hey there and thank you for opening this pull request!
            We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/)
            ℹ️ Details:
            ```
            ${{ steps.lint_pr_title.outputs.error_message || 'Everything is OK!' }}
            ```
     
      # Delete a previous comment when the issue has been resolved
      - if: ${{ always() && steps.lint_pr_title.outputs.error_message == null }}
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          header: ${{ github.job }}
          delete: true
          ignore_empty: false

And looks like examples with fixes were updated in #206

wzooff avatar Nov 29 '22 15:11 wzooff