Skip to content

Commit 61f8f70

Browse files
committed
chore: handle GitHub comment posting for forked PRs
1 parent 3186aee commit 61f8f70

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

badges/coverage.svg

+1-1
Loading

dist/index.js

+13-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github/handler.ts

+24-10
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,31 @@ async function postOrUpdatePRComment(
159159
core.info('Posting or updating PR comment')
160160
const newSummary = core.summary.stringify()
161161

162-
await handleComment(
163-
context.repo.owner,
164-
context.repo.repo,
165-
context.issue.number,
166-
newSummary,
167-
marker,
168-
{
169-
shouldUpdate: inputs.updateComment,
170-
shouldOverwrite: inputs.overwriteComment
162+
try {
163+
await handleComment(
164+
context.repo.owner,
165+
context.repo.repo,
166+
context.issue.number,
167+
newSummary,
168+
marker,
169+
{
170+
shouldUpdate: inputs.updateComment,
171+
shouldOverwrite: inputs.overwriteComment
172+
}
173+
)
174+
} catch (error) {
175+
if (
176+
error instanceof Error &&
177+
error.message.includes('Resource not accessible by integration')
178+
) {
179+
core.warning(
180+
'Unable to post PR comment - this is expected for pull_request events on fork PRs'
181+
)
182+
core.warning(
183+
'The comment must be posted by the pull_request_target workflow instead'
184+
)
171185
}
172-
)
186+
}
173187
}
174188

175189
/**

0 commit comments

Comments
 (0)