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
2 changes: 2 additions & 0 deletions src/lib/jobs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export const isFinalStatus = (st: Status): Boolean =>

export const isContributionJob = (job: Job): Boolean =>
job.contribution !== undefined

export const isCommentJob = (job: Job): Boolean => job.comment !== undefined
30 changes: 26 additions & 4 deletions src/status/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import {isContributionJob, isFinalStatus, get, required, Job} from '../lib'
import {
isContributionJob,
isFinalStatus,
get,
required,
Job,
isCommentJob
} from '../lib'
import * as core from '@actions/core'
import {track} from '../lib/track'

Expand All @@ -12,9 +19,19 @@ const isApproved = (job: Job): boolean =>
isContributionJob(job) &&
job.contribution?.result === 'approved'

const getJobType = (job: Job): string => {
if (isContributionJob(job)) {
return 'contribution'
}
if (isCommentJob(job)) {
return 'comment'
}
return 'unknown'
}

const run = async (
jobID: string
): Promise<{isApproved: boolean; isSuggested: boolean}> => {
): Promise<{isApproved: boolean; isSuggested: boolean; jobType: string}> => {
core.info(`Job ID: ${jobID}`)

let job = await get(jobID)
Expand All @@ -29,16 +46,21 @@ const run = async (
job = await get(jobID)
}

return {isApproved: isApproved(job), isSuggested: isSuggested(job)}
return {
isApproved: isApproved(job),
isSuggested: isSuggested(job),
jobType: getJobType(job)
}
}

const jobID = required('codeball-job-id')

run(jobID)
.then(async ({isApproved, isSuggested}) => {
.then(async ({isApproved, isSuggested, jobType}) => {
await track({jobID, actionName: 'status'})
core.setOutput('approved', isApproved)
core.setOutput('suggested', isSuggested)
core.setOutput('jobType', jobType)
})
.catch(async error => {
if (error instanceof Error) {
Expand Down
2 changes: 2 additions & 0 deletions status/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ inputs:
required: true

outputs:
jobType:
description: 'The type of Codeball job ("contribution" or "comment")'
approved:
description: 'If the Codeball approved the contribution (true or false)'
suggested:
Expand Down