Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/approver/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {Octokit, optional, required} from '../lib'
import {features, Octokit, optional, required} from '../lib'
import {ForbiddenError} from '../lib/api'
import {approve} from '../lib/github'
import {track} from '../lib/track'
Expand Down Expand Up @@ -59,14 +59,23 @@ async function run(): Promise<void> {
const isFromFork = pr.head.repo?.fork
const isToFork = pr.base.repo.fork

const feats = await features({jobID})

if (!feats.approve) {
core.error(
'Unable to run this action as the feature is not available for your organization. Please upgrade your Codeball plan, or contact support@codeball.ai'
)
return
}

await octokit.pulls
.createReview({
owner: repoOwner,
repo: repoName,
pull_number: pullRequestNumber,
commit_id: commitId,
body: reviewMessage,
event: 'APPROVE'
event: feats.approve ? 'APPROVE' : 'COMMENT'
})
.catch(async error => {
if (
Expand Down
10 changes: 9 additions & 1 deletion src/labeler/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {Octokit, optional, required} from '../lib'
import {Octokit, optional, required, features} from '../lib'
import {label as labelViaAPI} from '../lib/github'
import {ForbiddenError} from '../lib/api'
import {track} from '../lib/track'
Expand Down Expand Up @@ -117,6 +117,14 @@ const run = async (): Promise<void> => {
const labelDescription = required('description')
const removeLabelNames = optional('remove-label-names')

const feats = await features({jobID})
if (!feats.label) {
core.error(
'Unable to run this action as the feature is not available for your organization. Please upgrade your Codeball plan, or contact support@codeball.ai'
)
return
}

const pr = await octokit.pulls
.get({
owner: repoOwner,
Expand Down
20 changes: 20 additions & 0 deletions src/lib/features/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {get} from '../api'

export type Features = {
approve: boolean
label: boolean
}

export const features = async ({
jobID
}: {
jobID?: string
}): Promise<Features> => {
if (!jobID) {
return {
approve: true,
label: true
}
}
return get(`/jobs/${jobID}`).catch(error => console.warn(error))
}
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './jobs'
export * from './octokit'
export * from './track'
export * from './github'
export * from './features'