From e7719f14c5cc8c748e15afb42b6f4d2a3d6d9090 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 30 Oct 2025 01:55:58 +0900 Subject: [PATCH 1/2] fix: Prevent duplicate comments by validation workflow --- .github/workflows/validate-lockfile.yml | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate-lockfile.yml b/.github/workflows/validate-lockfile.yml index 59a6df96d..6a1e532ea 100644 --- a/.github/workflows/validate-lockfile.yml +++ b/.github/workflows/validate-lockfile.yml @@ -55,16 +55,41 @@ jobs: exit 1 fi + - name: Find existing lockfile validation comment + if: always() + uses: peter-evans/find-comment@v3 + id: find-comment + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: 'Lockfile Validation Failed' + - name: Comment on PR if validation failed if: failure() - uses: peter-evans/create-or-update-comment@v4 + uses: peter-evans/create-or-update-comment@v5 with: token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} + comment-id: ${{ steps.find-comment.outputs.comment-id }} + edit-mode: replace body: | + ❌ **Lockfile Validation Failed** + The following issue(s) were detected: ${{ steps.validate.outputs.errors }} Please address these and push an update. _Posted automatically by GitHub Actions_ + + - name: Delete comment if validation passed + if: success() && steps.find-comment.outputs.comment-id != '' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: ${{ steps.find-comment.outputs.comment-id }}, + }); From 58137aa63172a5518a92ab086ee35ecc463044b6 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 30 Oct 2025 01:56:18 +0900 Subject: [PATCH 2/2] feat: Allow validation workflow to run on forks --- .github/workflows/validate-lockfile.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate-lockfile.yml b/.github/workflows/validate-lockfile.yml index 6a1e532ea..119f43180 100644 --- a/.github/workflows/validate-lockfile.yml +++ b/.github/workflows/validate-lockfile.yml @@ -1,7 +1,7 @@ name: Validate pnpm-lock.yaml on: - pull_request: + pull_request_target: paths: - 'pnpm-lock.yaml' - '**/package.json' @@ -15,6 +15,8 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Set up Node.js uses: actions/setup-node@v4