Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation is leaving empty messages #216

Open
alec-eu opened this issue Nov 1, 2022 · 2 comments
Open

Validation is leaving empty messages #216

alec-eu opened this issue Nov 1, 2022 · 2 comments

Comments

@alec-eu
Copy link

alec-eu commented Nov 1, 2022

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
@amannn
Copy link
Owner

amannn commented Nov 1, 2022

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!

@wzooff
Copy link

wzooff commented Nov 29, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants