Skip to content

Commit

Permalink
Add output_text_description_file input (#24)
Browse files Browse the repository at this point in the history
* Add action input for output_text_description_file

* Actually apply file content to text_description
  • Loading branch information
Ben Reynolds authored Aug 23, 2021
1 parent 2a1af42 commit 3d24d48
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ Supports the following properties:

See [Check Runs API](https://developer.github.com/v3/checks/runs/#output-object) for more information

### `output_text_description_file`

_Optional_ Path to a file containing text which should be set as the `text_description` property of `output`'. Can contain plain text or markdown.

Note that this will be ignored if `output` is not provided. When `output` is provided with a text_description, this input will take precedence and override it.

### `annotations`

_Optional_ A JSON array (as a string) containing the annotations of your check, requires `output` to be included.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ inputs:
output:
description: 'the output of your check'
required: false
output_text_description_file:
description: 'path to a file containing text which should be set as the `text_description` of `output`'
required: false
annotations:
description: 'the annotations of your check'
required: false
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {InputOptions} from '@actions/core';
import * as Inputs from './namespaces/Inputs';
import fs from 'fs';

type GetInput = (name: string, options?: InputOptions | undefined) => string;

Expand All @@ -20,6 +21,7 @@ export const parseInputs = (getInput: GetInput): Inputs.Args => {
const repo = getInput('repo');
const sha = getInput('sha');
const token = getInput('token', {required: true});
const output_text_description_file = getInput('output_text_description_file');

const name = getInput('name');
const checkIDStr = getInput('check_id');
Expand Down Expand Up @@ -74,6 +76,10 @@ export const parseInputs = (getInput: GetInput): Inputs.Args => {
throw new Error(`missing value for 'action_url'`);
}

if (output && output_text_description_file) {
output.text_description = fs.readFileSync(output_text_description_file, 'utf8');
}

if ((!output || !output.summary) && (annotations || images)) {
throw new Error(`missing value for 'output.summary'`);
}
Expand Down

0 comments on commit 3d24d48

Please sign in to comment.