Skip to content

Commit

Permalink
Merge pull request #2 from sprucehealth/jon/non-pr-eveng
Browse files Browse the repository at this point in the history
fixes to support the reviewed status update
  • Loading branch information
sibljon authored Sep 11, 2024
2 parents 5134fac + 6b4b48c commit ddab98a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/main.js

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

28 changes: 16 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ export async function run(): Promise<void> {

const triggerIsPullRequest = github.context.eventName === 'pull_request';

const body = triggerIsPullRequest
? github.context.payload.pull_request?.body
: github.context.payload.commits?.[0]?.message;
const body =
github.context.payload.pull_request?.body ?? github.context.payload.commits?.[0]?.message;
if (!body) {
// core.info(`ℹ️ github.context: ${JSON.stringify(github.context)}`);
core.info(
`ℹ️ github.context.payload.pull_request: ${JSON.stringify(
github.context.payload.pull_request,
null,
2
)}`
);
core.info(`🛑 couldn't find PR body`);
return;
}
Expand Down Expand Up @@ -147,16 +154,13 @@ export async function run(): Promise<void> {
});
const reviews = reviewsData.data;

const latestReviews = (reviews ?? []).reduce(
(acc, review) => {
if (!review.user) {
return acc;
}
acc[review.user.login] = review;
const latestReviews = (reviews ?? []).reduce((acc, review) => {
if (!review.user) {
return acc;
},
{} as Record<string, (typeof reviews)[number]>
);
}
acc[review.user.login] = review;
return acc;
}, {} as Record<string, typeof reviews[number]>);

const latestReviewsArray = Object.values(latestReviews || {});
core.info(`🔍 latestReviewsArray: ${JSON.stringify(latestReviewsArray)}`);
Expand Down

0 comments on commit ddab98a

Please sign in to comment.