hashicorp / nextjs-bundle-analysis

A github action that provides detailed bundle analysis on PRs for next.js apps
Mozilla Public License 2.0
617 stars 35 forks source link

update comment not working, PR gets multiple comments #57

Open ethanryan opened 1 year ago

ethanryan commented 1 year ago

update comment is not working, example:

update-comment-not-working

this is causing multiple comments to appear with each new commit, instead of new commits replacing old comments.

Our PRs are getting multiple comments from nextjs-bundle-analysis github action. We get a comment when opening a new PR, and then a new comment on each new commit pushed.

For example:

next-analysis-multiple-comments

Previously, the comment would be replaced with each new commit.

We have other github actions that do not have this problem.

Any help would be greatly appreciated. Thanks!

(closed related issue, for multiple comments: https://github.com/hashicorp/nextjs-bundle-analysis/issues/56)

ethanryan commented 1 year ago

fixed this issue with solution offered in this closed issue: https://github.com/hashicorp/nextjs-bundle-analysis/issues/52#issuecomment-1507644855

You can upgrade right now by replacing the Find, Create, and Update steps with the following:

- name: Comment
  uses: marocchino/sticky-pull-request-comment@v2
  with:
    header: next-touched-pages
    message: ${{ steps.get-comment-body.outputs.body }}

may be helpful to keep this issue open for others facing this problem, until this PR fixing the issue is merged: https://github.com/hashicorp/nextjs-bundle-analysis/pull/54

isBatak commented 1 year ago

@ethanryan you can just update this line https://github.com/hashicorp/nextjs-bundle-analysis/blob/a4cf35f98ec1ecb5753ba966acde342fbd175319/template.yml#L113 and append you project name form package.json prefixed with _ For example:

// package.json
{
    "name": "my-app",
    ...
}
      - name: Find Comment
        uses: peter-evans/find-comment@v2
        if: success() && github.event.number
        id: fc
        with:
          issue-number: ${{ github.event.number }}
          body-includes: '<!-- __NEXTJS_BUNDLE_my-app -->'

e.g. '<!-- __NEXTJS_BUNDLE_${PROJECT_NAME} -->'