Skip to content
Permalink
Browse files
Make 'conclusion' optional unless 'status' is required, closes #4, ba…
…sed on @Akrog's fork
  • Loading branch information
LouisBrunner committed Sep 7, 2020
1 parent 8c74960 commit 51c8f468c1542786e63909240c0c43de11b3c347
Showing 7 changed files with 30 additions and 9 deletions.
@@ -200,6 +200,7 @@ jobs:
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Will not be used
status: completed
conclusion: failure

@@ -216,6 +217,7 @@ jobs:
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Will not be used
conclusion: failure

## Based on job
@@ -42,7 +42,7 @@ See the [examples workflow](.github/workflows/examples.yml) for more details and

### `conclusion`

**Required** The conclusion of your check, can be either `success`, `failure`, `neutral`, `cancelled`, `timed_out` or `action_required`
_Optional_ (**Required** if `status` is `completed`, the default) The conclusion of your check, can be either `success`, `failure`, `neutral`, `cancelled`, `timed_out` or `action_required`

### `status`

@@ -88,3 +88,4 @@ Supports the same properties with the same types and names as the [Check Runs AP
- Action Required conclusion: button doesn't work
- Action elements: button doesn't work
- Non-completed status: too many arguments required
- Name is required when completing a non-`completed` `status` check even though we don't use it (see examples `test_with_init*`)
@@ -13,7 +13,7 @@ inputs:
required: true
conclusion:
description: 'the conclusion of your check'
required: true
required: false
status:
description: 'the status of your check'
required: false

Large diffs are not rendered by default.

@@ -21,13 +21,18 @@ const unpackInputs = (inputs: Inputs.Args): Record<string, unknown> => {
images: inputs.images,
};
}
const more: {details_url?: string} = {};
const more: {
details_url?: string;
conclusion?: string;
} = {};
if (inputs.conclusion === Inputs.Conclusion.ActionRequired || inputs.actions) {
more.details_url = inputs.actionURL;
}
if (inputs.conclusion) {
more.conclusion = inputs.conclusion.toString();
}
return {
status: inputs.status.toString(),
conclusion: inputs.conclusion.toString(),
output,
actions: inputs.actions,
...more,
@@ -20,15 +20,28 @@ export const parseInputs = (getInput: GetInput): Inputs.Args => {
const token = getInput('token', {required: true});
const name = getInput('name', {required: true});
const status = getInput('status', {required: true}) as Inputs.Status;
const conclusion = getInput('conclusion', {required: true}).toLowerCase() as Inputs.Conclusion;
let conclusion = getInput('conclusion') as Inputs.Conclusion;
const actionURL = getInput('action_url');

if (!Object.values(Inputs.Status).includes(status)) {
throw new Error(`invalid value for 'status': '${status}'`);
}

if (!Object.values(Inputs.Conclusion).includes(conclusion)) {
throw new Error(`invalid value for 'conclusion': '${conclusion}'`);
if (conclusion) {
conclusion = conclusion.toLowerCase() as Inputs.Conclusion;
if (!Object.values(Inputs.Conclusion).includes(conclusion)) {
throw new Error(`invalid value for 'conclusion': '${conclusion}'`);
}
}

if (status === Inputs.Status.Completed) {
if (!conclusion) {
throw new Error(`'conclusion' is required when 'status' is 'completed'`);
}
} else {
if (conclusion) {
throw new Error(`can't provide a 'conclusion' with a non-'completed' 'status'`);
}
}

const output = parseJSON<Inputs.Output>(getInput, 'output');
@@ -3,7 +3,7 @@ import {RestEndpointMethodTypes} from '@octokit/rest';
export type Args = {
name: string;
token: string;
conclusion: Conclusion;
conclusion?: Conclusion;
status: Status;

actionURL: string;

0 comments on commit 51c8f46

Please sign in to comment.