Skip to content

Commit f28f3c2

Browse files
authored
Merge pull request #7116 from mermaid-js/sidv/lockfileValidation
fix: Lockfile validation
2 parents 35d9cea + 58137aa commit f28f3c2

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

.github/workflows/validate-lockfile.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Validate pnpm-lock.yaml
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
paths:
66
- 'pnpm-lock.yaml'
77
- '**/package.json'
@@ -15,6 +15,8 @@ jobs:
1515
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
repository: ${{ github.event.pull_request.head.repo.full_name }}
1820

1921
- name: Set up Node.js
2022
uses: actions/setup-node@v4
@@ -55,16 +57,41 @@ jobs:
5557
exit 1
5658
fi
5759
60+
- name: Find existing lockfile validation comment
61+
if: always()
62+
uses: peter-evans/find-comment@v3
63+
id: find-comment
64+
with:
65+
issue-number: ${{ github.event.pull_request.number }}
66+
comment-author: 'github-actions[bot]'
67+
body-includes: 'Lockfile Validation Failed'
68+
5869
- name: Comment on PR if validation failed
5970
if: failure()
60-
uses: peter-evans/create-or-update-comment@v4
71+
uses: peter-evans/create-or-update-comment@v5
6172
with:
6273
token: ${{ secrets.GITHUB_TOKEN }}
6374
issue-number: ${{ github.event.pull_request.number }}
75+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
76+
edit-mode: replace
6477
body: |
78+
❌ **Lockfile Validation Failed**
79+
6580
The following issue(s) were detected:
6681
${{ steps.validate.outputs.errors }}
6782
6883
Please address these and push an update.
6984
7085
_Posted automatically by GitHub Actions_
86+
87+
- name: Delete comment if validation passed
88+
if: success() && steps.find-comment.outputs.comment-id != ''
89+
uses: actions/github-script@v7
90+
with:
91+
github-token: ${{ secrets.GITHUB_TOKEN }}
92+
script: |
93+
await github.rest.issues.deleteComment({
94+
owner: context.repo.owner,
95+
repo: context.repo.repo,
96+
comment_id: ${{ steps.find-comment.outputs.comment-id }},
97+
});

0 commit comments

Comments
 (0)