Skip to content

Commit 5546e01

Browse files
committed
add pr state check
1 parent 7299df1 commit 5546e01

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/app/server/routes/publish.post.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,24 @@ export default eventHandler(async (event) => {
230230
}
231231

232232
if (isPullRequest(workflowData.ref)) {
233+
try {
234+
const { data: pr } = await installation.request("GET /repos/{owner}/{repo}/pulls/{pull_number}", {
235+
owner: workflowData.owner,
236+
repo: workflowData.repo,
237+
pull_number: Number(workflowData.ref),
238+
});
239+
240+
if (pr.state !== 'open') {
241+
console.log(`skipping comment on ${pr.state} PR #${pr.number}`);
242+
return {
243+
ok: true,
244+
urls,
245+
};
246+
}
247+
} catch (error) {
248+
console.error("failed to check PR state", error);
249+
}
250+
233251
let prevComment: OctokitComponents["schemas"]["issue-comment"];
234252

235253
await installation.paginate(

0 commit comments

Comments
 (0)