11name : Validate Plugin TOML
22
33on :
4- pull_request :
4+ pull_request_target :
55 branches :
66 - master
77 paths :
88 - ' plugins/**'
99
1010permissions :
11+ contents : read
12+ issues : write
1113 pull-requests : write
1214
1315jobs :
@@ -20,11 +22,12 @@ jobs:
2022 with :
2123 submodules : recursive
2224 fetch-depth : 0
25+ ref : ${{ github.event.pull_request.head.sha }}
2326
2427 - name : Get changed plugins
2528 id : changed
2629 run : |
27- CHANGED_PLUGINS=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '^plugins/' | cut -d'/' -f2 | sort -u | tr '\n' ' ')
30+ CHANGED_PLUGINS=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.event.pull_request.head.sha }} | grep '^plugins/' | cut -d'/' -f2 | sort -u | tr '\n' ' ')
2831 echo "plugins=$CHANGED_PLUGINS" >> $GITHUB_OUTPUT
2932 echo "Changed plugins: $CHANGED_PLUGINS"
3033
5356 run : |
5457 pnpm validate ${{ steps.changed.outputs.plugins }}
5558 echo "result=success" >> $GITHUB_OUTPUT
56- # If validation fails (exit 1), continue-on-error keeps the workflow running
57- # but 'result=success' won't be written to GITHUB_OUTPUT
5859
5960 - name : Post validation comment
6061 if : always() && steps.changed.outputs.plugins != ''
@@ -72,28 +73,37 @@ jobs:
7273 body = marker + '\n## Plugin TOML Validation Report\n\n> No validation report generated.';
7374 }
7475
75- const { data: comments } = await github.rest.issues.listComments({
76- owner: context.repo.owner,
77- repo: context.repo.repo,
78- issue_number: context.issue.number,
79- });
80-
81- const existing = comments.find(c => c.body && c.body.includes(marker));
82-
83- if (existing) {
84- await github.rest.issues.updateComment({
85- owner: context.repo.owner,
86- repo: context.repo.repo,
87- comment_id: existing.id,
88- body,
89- });
90- } else {
91- await github.rest.issues.createComment({
76+ try {
77+ const { data: comments } = await github.rest.issues.listComments({
9278 owner: context.repo.owner,
9379 repo: context.repo.repo,
9480 issue_number: context.issue.number,
95- body,
9681 });
82+
83+ const existing = comments.find(c => c.body && c.body.includes(marker));
84+
85+ if (existing) {
86+ await github.rest.issues.updateComment({
87+ owner: context.repo.owner,
88+ repo: context.repo.repo,
89+ comment_id: existing.id,
90+ body,
91+ });
92+ } else {
93+ await github.rest.issues.createComment({
94+ owner: context.repo.owner,
95+ repo: context.repo.repo,
96+ issue_number: context.issue.number,
97+ body,
98+ });
99+ }
100+ } catch (error) {
101+ if (error.status === 403) {
102+ core.warning(`Skipping PR comment because the workflow token cannot write comments: ${error.message}`);
103+ return;
104+ }
105+
106+ throw error;
97107 }
98108
99109 - name : Fail if validation failed
0 commit comments