Skip to content

Commit a46d20f

Browse files
authored
Merge pull request #173 from backstage/rugvip/author
pr-automation: add actor override input and remove comment review scoring + bot check
2 parents c0110c1 + b1418ce commit a46d20f

3 files changed

Lines changed: 11 additions & 31 deletions

File tree

pr-automation/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ inputs:
2929
description: Simulate a label being added (implies labeled action)
3030
required: false
3131
review-state:
32-
description: Simulate a review submission with this state (approved, changes_requested, commented)
32+
description: Simulate a review submission with this state (approved, changes_requested)
33+
required: false
34+
actor:
35+
description: Override for the actor (user who triggered the event)
3336
required: false
3437
outputs: {}
3538
runs:

pr-automation/collectInput.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ interface EventContext {
2020
repo: string;
2121
actor: string;
2222
labelAdded?: string;
23-
commentAuthorLogin?: string;
2423
reviewState?: string;
2524
}
2625

@@ -186,15 +185,6 @@ export async function collectInput(
186185
};
187186

188187
const client = createAppClient();
189-
const botLogin = await getBotLogin(client);
190-
191-
if (
192-
botLogin &&
193-
(event.actor === botLogin || event.commentAuthorLogin === botLogin)
194-
) {
195-
core.info(`Skipping: triggered by bot (${botLogin})`);
196-
return null;
197-
}
198188

199189
const data = await getPrAutomationData(client, {
200190
owner: ensuredEvent.owner,
@@ -232,9 +222,10 @@ export async function collectInput(
232222
}
233223

234224
function getEventContext(): RawEventContext {
235-
const prNumberInput = core.getInput('pr-number');
236-
const labelAddedInput = core.getInput('label-added');
237-
const reviewStateInput = core.getInput('review-state');
225+
const prNumberInput = core.getInput('pr-number') || undefined;
226+
const labelAddedInput = core.getInput('label-added') || undefined;
227+
const reviewStateInput = core.getInput('review-state') || undefined;
228+
const actorInput = core.getInput('actor') || undefined;
238229

239230
// Infer event type from inputs
240231
let eventName = github.context.eventName;
@@ -253,15 +244,14 @@ function getEventContext(): RawEventContext {
253244
action,
254245
owner: github.context.repo.owner,
255246
repo: github.context.repo.repo,
256-
actor: github.context.actor,
247+
actor: actorInput ?? github.context.actor,
257248
labelAdded:
258-
labelAddedInput ||
249+
labelAddedInput ??
259250
(github.context.payload.action === 'labeled'
260251
? github.context.payload.label?.name
261252
: undefined),
262-
commentAuthorLogin: github.context.payload.comment?.user?.login,
263253
reviewState:
264-
reviewStateInput ||
254+
reviewStateInput ??
265255
(github.context.payload.review?.state as string | undefined),
266256
};
267257
}
@@ -276,17 +266,6 @@ function getPrNumber() {
276266
return undefined;
277267
}
278268

279-
async function getBotLogin(
280-
client: ReturnType<typeof github.getOctokit>,
281-
): Promise<string | null> {
282-
try {
283-
const app = await client.rest.apps.getAuthenticated();
284-
return app.data.slug ? `${app.data.slug}[bot]` : null;
285-
} catch {
286-
return null;
287-
}
288-
}
289-
290269
async function listTeamMembers(
291270
client: ReturnType<typeof github.getOctokit>,
292271
org: string,

pr-automation/reviewerScoreLedger.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ const STATUS_FIELD_NAME = 'Status';
1111
const REVIEW_SCORES: Record<string, number> = {
1212
APPROVED: 2,
1313
CHANGES_REQUESTED: 3,
14-
COMMENTED: 1,
1514
};
1615

1716
const REVIEW_STATUS_LABELS: Record<string, string> = {
1817
APPROVED: 'Approve',
1918
CHANGES_REQUESTED: 'Request changes',
20-
COMMENTED: 'Comment',
2119
};
2220

2321
interface ProjectData {

0 commit comments

Comments
 (0)