Skip to content

Commit 952d784

Browse files
committed
fix(actions): gracefully handle 403 on fork PRs when commenting
1 parent 64b9024 commit 952d784

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

.github/changeset-preview/upsert-pr-comment.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ async function githubRequest({ apiUrl, token, method, endpoint, body }) {
6868

6969
if (!response.ok) {
7070
const text = await response.text()
71+
if (response.status === 403) {
72+
process.stdout.write(
73+
`Warning: ${method} ${endpoint} returned 403. This is expected for fork PRs where the token has read-only access.\n`,
74+
)
75+
return undefined
76+
}
7177
throw new Error(
7278
`${method} ${endpoint} failed (${response.status} ${response.statusText}): ${text}`,
7379
)

0 commit comments

Comments
 (0)