Skip to content

Commit

Permalink
fix: add needsReview label in renovate pr that are not automerged
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed Aug 6, 2019
1 parent e4417dc commit 2247461
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/pr-handlers/actions/autoApproveAndAutoMerge.ts
Expand Up @@ -6,15 +6,17 @@ import { autoMergeIfPossible } from './autoMergeIfPossible';
export const autoApproveAndAutoMerge = async (
context: Context<Webhooks.WebhookPayloadPullRequest>,
repoContext: RepoContext,
): Promise<void> => {
): Promise<boolean> => {
// const autoMergeLabel = repoContext.labels['merge/automerge'];
const codeApprovedLabel = repoContext.labels['code/approved'];
const prLabels = context.payload.pull_request.labels;
if (prLabels.find((l): boolean => l.id === codeApprovedLabel.id)) {
await context.github.pulls.createReview(
context.issue({ event: 'APPROVE' }),
);
await autoMergeIfPossible(context, repoContext);
return true;
}

await autoMergeIfPossible(context, repoContext);
return false;
};
10 changes: 9 additions & 1 deletion src/pr-handlers/opened.ts
Expand Up @@ -18,7 +18,15 @@ export default function opened(app: Application): void {
autoAssignPRToCreator(context, repoContext),
editOpenedPR(context, repoContext),
fromRenovate
? autoApproveAndAutoMerge(context, repoContext)
? autoApproveAndAutoMerge(context, repoContext).then(
async (approved: boolean): Promise<void> => {
if (!approved) {
await updateReviewStatus(context, repoContext, 'dev', {
add: ['needsReview'],
});
}
},
)
: updateReviewStatus(context, repoContext, 'dev', {
add: ['needsReview'],
remove: ['approved', 'changesRequested'],
Expand Down

0 comments on commit 2247461

Please sign in to comment.