Skip to content

Commit

Permalink
update for target label
Browse files Browse the repository at this point in the history
  • Loading branch information
anc95 committed Apr 28, 2023
1 parent a6c8441 commit c2e66b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions action/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -148173,6 +148173,12 @@ const robot = (app) => {
pull_request.draft) {
return 'invalid event paylod';
}
const target_label = process.env.TARGET_LABEL;
if (target_label &&
(!pull_request.labels?.length ||
pull_request.labels.every((label) => label.name !== target_label))) {
return 'no target label attached';
}
const data = await context.octokit.repos.compareCommits({
owner: repo.owner,
repo: repo.repo,
Expand Down
17 changes: 12 additions & 5 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ export const robot = (app: Probot) => {
return 'invalid event paylod';
}

const target_label = process.env.TARGET_LABEL
if (target_label && pull_request.labels.every(label => label.name !== target_label)) {
return "no target label attached"
const target_label = process.env.TARGET_LABEL;
if (
target_label &&
(!pull_request.labels?.length ||
pull_request.labels.every((label) => label.name !== target_label))
) {
return 'no target label attached';
}

const data = await context.octokit.repos.compareCommits({
Expand Down Expand Up @@ -99,7 +103,7 @@ export const robot = (app: Probot) => {
const file = changedFiles[i];
const patch = file.patch || '';

if(file.status !== 'modified' && file.status !== 'added') {
if (file.status !== 'modified' && file.status !== 'added') {
continue;
}

Expand All @@ -122,7 +126,10 @@ export const robot = (app: Probot) => {
}

console.timeEnd('gpt cost');
console.info('successfully reviewed', context.payload.pull_request.html_url);
console.info(
'successfully reviewed',
context.payload.pull_request.html_url
);

return 'success';
}
Expand Down

0 comments on commit c2e66b7

Please sign in to comment.