Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian committed Oct 10, 2024
1 parent e5ce6ac commit d61246f
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 15 deletions.
29 changes: 25 additions & 4 deletions dist/284.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/284.index.js.map

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions dist/946.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/946.index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/helpers/manage-merge-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { approvalsSatisfied } from './approvals-satisfied';
import { createPrComment } from './create-pr-comment';
import { isUserInTeam } from './is-user-in-team';
import { join } from 'path';
import { getEmailOnUserProfile } from '../utils/get-email-on-user-profile';

export class ManageMergeQueue extends HelperInputs {
max_queue_size?: string;
Expand Down Expand Up @@ -63,13 +64,12 @@ export const manageMergeQueue = async ({
return removePrFromQueue(pullRequest);
}
if (slack_webhook_url && login) {
const {
data: { email }
} = await octokit.users.getByUsername({ username: login });
const email = await getEmailOnUserProfile(login);
if (!email) {
return removePrFromQueue(pullRequest);
}
}

const queuedPrs = await getQueuedPullRequests();
const queuePosition = queuedPrs.length + 1;

Expand Down
9 changes: 9 additions & 0 deletions src/utils/get-email-on-user-profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { octokit } from '../octokit';

export async function getEmailOnUserProfile(login: string) {
const {
data: { email }
} = await octokit.users.getByUsername({ username: login });

return email;
}
5 changes: 2 additions & 3 deletions src/utils/notify-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import axios from 'axios';
import { context } from '@actions/github';
import { octokit } from '../octokit';
import { createPrComment } from '../helpers/create-pr-comment';
import { getEmailOnUserProfile } from './get-email-on-user-profile';

interface NotifyUser {
login: string;
Expand All @@ -26,9 +27,7 @@ interface NotifyUser {

export const notifyUser = async ({ login, pull_number, slack_webhook_url, comment_body }: NotifyUser) => {
core.info(`Notifying user ${login}...`);
const {
data: { email }
} = await octokit.users.getByUsername({ username: login });
const email = await getEmailOnUserProfile(login);
if (!email && comment_body) {
return await createPrComment({
body: comment_body
Expand Down

0 comments on commit d61246f

Please sign in to comment.