Skip to content

Commit 25cdc01

Browse files
authored
fix: skip draft PRs from processing (#323)
Draft PRs cannot be merged by GitHub and attempting to do so results in a 405 error. This change skips draft PRs in both scheduled processing and webhook handling to avoid unnecessary API calls and error logs. Closes #199
1 parent 94b2b9c commit 25cdc01

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/helpers/pullRequestProcessor.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ export async function processPullRequests() {
122122
console.log(`Found ${pullRequests.length} pull requests`);
123123

124124
for (const pullRequest of pullRequests) {
125+
// Skip draft PRs - they cannot be merged and should not be processed
126+
if (pullRequest.draft) {
127+
console.log(
128+
`⏸️ Skipping draft PR #${pullRequest.number}: ${pullRequest.title}`
129+
);
130+
continue;
131+
}
132+
125133
const prResult = {
126134
number: pullRequest.number,
127135
title: pullRequest.title,
@@ -305,6 +313,11 @@ export async function processRepositoryPullRequests(owner, repo) {
305313
const results = [];
306314

307315
for (const pullRequest of pullRequests) {
316+
// Skip draft PRs
317+
if (pullRequest.draft) {
318+
continue;
319+
}
320+
308321
const pullRequestData = await getPullRequestData(
309322
githubClient,
310323
owner,

src/helpers/webhookHandler.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ export async function handlePullRequestWebhook(data) {
120120
return { error: 'No GitHub App configured' };
121121
}
122122

123+
// Skip draft PRs - they cannot be merged and should not be processed
124+
if (pullRequest.draft) {
125+
console.log(
126+
`⏸️ Skipping draft PR #${pullRequest.number}: ${pullRequest.title}`
127+
);
128+
return { info: 'Draft PR skipped' };
129+
}
130+
123131
try {
124132
const installationId = dbRepository.installationId;
125133

@@ -204,6 +212,14 @@ export async function handlePullRequestReviewWebhook(data) {
204212
return { error: 'No GitHub App configured' };
205213
}
206214

215+
// Skip draft PRs
216+
if (pullRequest.draft) {
217+
console.log(
218+
`⏸️ Skipping review for draft PR #${pullRequest.number}: ${pullRequest.title}`
219+
);
220+
return { info: 'Draft PR review skipped' };
221+
}
222+
207223
try {
208224
const installationId = dbRepository.installationId;
209225

0 commit comments

Comments
 (0)