Skip to content

Commit

Permalink
Add AuthorAssociation type.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Oct 28, 2022
1 parent f29d23f commit ef20125
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -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']

Expand All @@ -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} ` +
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { components as OCTOKIT_OPENAPI_TYPES } from '@octokit/openapi-types'

export type Octokit = ReturnType<typeof github.getOctokit>

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']
Expand Down

0 comments on commit ef20125

Please sign in to comment.