From ef20125c2bc7bef55ffb99d7e0bd4aada2e29035 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 28 Oct 2022 10:47:57 +0200 Subject: [PATCH] Add `AuthorAssociation` type. --- src/helpers.ts | 16 +++++++++++++--- src/types.ts | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index f1172ffe0cc4..2ef5801b32de 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -1,7 +1,17 @@ import * as core from '@actions/core' import * as github from '@actions/github' -import { CheckRun, CheckSuite, CommitStatus, Octokit, PullRequest, Repo, Review, WorkflowRun } from './types' +import { + AuthorAssociation, + CheckRun, + CheckSuite, + CommitStatus, + Octokit, + PullRequest, + Repo, + Review, + WorkflowRun, +} from './types' export const UNMERGEABLE_STATES = ['blocked'] @@ -28,7 +38,7 @@ export function isAuthorAllowed( return authorAssociations.includes(pullRequestOrReview.author_association) } -export function isReviewAuthorAllowed(review: Review, authorAssociations: string[]): boolean { +export function isReviewAuthorAllowed(review: Review, authorAssociations: AuthorAssociation[]): boolean { if (!isAuthorAllowed(review, authorAssociations)) { core.debug( `Author @${review.user?.login} of review ${review.id} ` + @@ -42,7 +52,7 @@ export function isReviewAuthorAllowed(review: Review, authorAssociations: string return true } -export function isApprovedByAllowedAuthor(review: Review, authorAssociations: string[]): boolean { +export function isApprovedByAllowedAuthor(review: Review, authorAssociations: AuthorAssociation[]): boolean { if (!isApproved(review)) { core.debug(`Review ${review.id} is not an approval.`) return false diff --git a/src/types.ts b/src/types.ts index b97c0d702515..6526827a2d40 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,6 +3,7 @@ import { components as OCTOKIT_OPENAPI_TYPES } from '@octokit/openapi-types' export type Octokit = ReturnType +export type AuthorAssociation = OCTOKIT_OPENAPI_TYPES['schemas']['author-association'] export type CheckRun = OCTOKIT_OPENAPI_TYPES['schemas']['check-run'] export type CheckSuite = OCTOKIT_OPENAPI_TYPES['schemas']['check-suite'] export type PullRequest = OCTOKIT_OPENAPI_TYPES['schemas']['pull-request']