From 1067c118665d461075656768dd6f02826cdc1ec7 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 15:51:40 +0000 Subject: [PATCH 1/2] Replace third-party comment action with native gh CLI Co-Authored-By: kenny@buildwithfern.com --- .github/workflows/preview-docs.yml | 34 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml index e326885d7..0d270990e 100644 --- a/.github/workflows/preview-docs.yml +++ b/.github/workflows/preview-docs.yml @@ -143,8 +143,32 @@ jobs: echo ":herb: **Preview your docs:** <${{ steps.generate-docs.outputs.preview_url }}>" > comment.md - name: Post PR comment - uses: thollander/actions-comment-pull-request@v2.4.3 - with: - filePath: comment.md - comment_tag: preview-docs - mode: upsert + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Add a hidden marker to identify this comment for future updates + echo "" >> comment.md + + PR_NUMBER=${{ github.event.pull_request.number }} + COMMENT_BODY=$(cat comment.md) + + # Find existing comment with our marker + EXISTING_COMMENT_ID=$(gh api \ + -H "Accept: application/vnd.github+json" \ + "/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \ + --jq '.[] | select(.body | contains("")) | .id' \ + | head -n 1) + + if [ -n "$EXISTING_COMMENT_ID" ]; then + # Update existing comment + gh api \ + --method PATCH \ + -H "Accept: application/vnd.github+json" \ + "/repos/${{ github.repository }}/issues/comments/${EXISTING_COMMENT_ID}" \ + -f body="$COMMENT_BODY" + echo "Updated existing comment $EXISTING_COMMENT_ID" + else + # Create new comment + gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY" + echo "Created new comment" + fi From 3f87be7001c4b391827e5ab55ce0f22e5acd800c Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 15:59:46 +0000 Subject: [PATCH 2/2] Use actions/github-script instead of gh CLI for PR comments Co-Authored-By: kenny@buildwithfern.com --- .github/workflows/preview-docs.yml | 61 ++++++++++++++++-------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml index 0d270990e..87844777e 100644 --- a/.github/workflows/preview-docs.yml +++ b/.github/workflows/preview-docs.yml @@ -143,32 +143,35 @@ jobs: echo ":herb: **Preview your docs:** <${{ steps.generate-docs.outputs.preview_url }}>" > comment.md - name: Post PR comment - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Add a hidden marker to identify this comment for future updates - echo "" >> comment.md - - PR_NUMBER=${{ github.event.pull_request.number }} - COMMENT_BODY=$(cat comment.md) - - # Find existing comment with our marker - EXISTING_COMMENT_ID=$(gh api \ - -H "Accept: application/vnd.github+json" \ - "/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \ - --jq '.[] | select(.body | contains("")) | .id' \ - | head -n 1) - - if [ -n "$EXISTING_COMMENT_ID" ]; then - # Update existing comment - gh api \ - --method PATCH \ - -H "Accept: application/vnd.github+json" \ - "/repos/${{ github.repository }}/issues/comments/${EXISTING_COMMENT_ID}" \ - -f body="$COMMENT_BODY" - echo "Updated existing comment $EXISTING_COMMENT_ID" - else - # Create new comment - gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY" - echo "Created new comment" - fi + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const commentBody = fs.readFileSync('comment.md', 'utf8') + '\n'; + const marker = ''; + + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number + }); + + const existingComment = comments.find(comment => comment.body.includes(marker)); + + if (existingComment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existingComment.id, + body: commentBody + }); + console.log(`Updated existing comment ${existingComment.id}`); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: commentBody + }); + console.log('Created new comment'); + }