Last active
November 8, 2019 17:51
-
-
Save uc-compass-bot/0482affa54e8fe202866b6dcf0703f5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Context} from 'probot/lib/context'; | |
import {ChecksUpdateParamsOutput} from '@octokit/rest'; | |
import {WebhookPayloadPullRequest} from '@octokit/webhooks'; | |
import CheckRun, {ICheckRun} from './CheckRun'; | |
export default class SampleCheck extends CheckRun implements ICheckRun { | |
static checkName: string = 'my-cool-check'; | |
public payload: WebhookPayloadPullRequest; | |
constructor(event: Context) { | |
super(SampleCheck.checkName, event); | |
this.payload = event.payload; | |
} | |
async run(): Promise<void> { | |
const output: ChecksUpdateParamsOutput = {summary: ''}; // The API requires a summary no matter the outcome | |
// Updates the GitHub UI to switch the status from "queued" to "in progress" | |
await this.update('in_progress'); | |
// Do some sort of business logic here. For this example, we'll randomly pass or fail | |
const success = Math.random() >= 0.5; | |
if (!success) { | |
output.title = 'Failed coin toss' | |
output.summary = 'Luck is not on your side today, you failed to be pass the test.' | |
} | |
await this.finish(success, output); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment