From 6723a55710d05cf6bbcff40f2a15c151c2d3d466 Mon Sep 17 00:00:00 2001 From: Jason Fry Date: Wed, 7 Dec 2022 21:05:08 -0500 Subject: [PATCH] get actor https://github.com/actions/labeler/issues/100 --- src/labeler.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/labeler.ts b/src/labeler.ts index 97ecb16a8..1941c2f60 100644 --- a/src/labeler.ts +++ b/src/labeler.ts @@ -22,12 +22,13 @@ export async function run() { console.log("Could not get pull request number from context, exiting"); return; } + const actor = getActor(); /* TODO * * [Assigns labels based on branch names](https://github.com/actions/labeler/pull/203/files) * [Assign label based on status](https://github.com/actions/labeler/pull/79/files) * - * - [ ] if list is nonempty, get actor https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts#L17 + * - [x] get actor https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts#L17 * - [ ] find actor in list of provided actors * - [ ] if found, add label(s) * - [ ] if not found, do nothing @@ -81,6 +82,15 @@ function getPrNumber(): number | undefined { return pullRequest.number; } +function getActor(): string[] { + const actor = github.context.actor; + if (!actor) { + return undefined; + } + + return actor; +} + async function getChangedFiles( client: ClientType, prNumber: number