Skip to content
Permalink
Browse files
Fix build pipeline
  • Loading branch information
LouisBrunner committed Feb 29, 2020
1 parent 7420dc9 commit 297d38e67227bd87efedf3ad97cce96b180777a5
Showing 6 changed files with 42 additions and 18 deletions.
@@ -77,17 +77,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Basic Action Required
conclusion: action_required

## Based on command
test_with_annotation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Advanced With Output
conclusion: success
action_url: https://example.com

## With annotations
test_with_annotations:
@@ -111,7 +101,10 @@ jobs:
- uses: actions/checkout@v1
- id: annotations
run: |
echo ::set-output name=value::{"path":"README.md","start_line":1,"end_line":2,"message":"Check your spelling for 'banaas'.","annotation_level":"warning"}
echo ::set-output name=value::$ANNOTATIONS
env:
ANNOTATIONS: |
{"path":"README.md","start_line":1,"end_line":2,"message":"Check your spelling for 'banaas'.","annotation_level":"warning"}
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
@@ -144,7 +137,10 @@ jobs:
- uses: actions/checkout@v1
- id: images
run: |
echo ::set-output name=value::{"alt":"Cool pic","image_url":"https://via.placeholder.com/150","caption":"Cool description"}
echo ::set-output name=value::$IMAGES
env:
IMAGES: |
{"alt":"Cool pic","image_url":"https://via.placeholder.com/150","caption":"Cool description"}
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
@@ -166,6 +162,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Actions
conclusion: success
action_url: https://example.com
actions: |
[{"label":"Click Me","description":"Click me to get free RAM","identifier":"sent_to_webhook"}]
@@ -175,12 +172,16 @@ jobs:
- uses: actions/checkout@v1
- id: actions
run: |
echo ::set-output name=value::{"label":"Click Me","description":"Click me to get free RAM","identifier":"sent_to_webhook"}
echo ::set-output name=value::$ACTIONS
env:
ACTIONS: |
{"label":"Click Me","description":"Click me to get free RAM","identifier":"sent_to_webhook"}
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Actions From Run
conclusion: success
action_url: https://example.com
# output.summary is required with actions!
output: |
{"summary":"Some warnings in README.md"}
@@ -227,7 +228,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Based On Job (Success)
conclusion: ${{ job }}
conclusion: ${{ job.status }}

test_based_job_failure:
runs-on: ubuntu-latest
@@ -239,4 +240,4 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Based On Job (Failure)
conclusion: ${{ job }}
conclusion: ${{ job.status }}
@@ -15,6 +15,9 @@ inputs:
description: 'the status of your check'
required: false
default: completed
action_url:
description: 'the url to link to when using action_required as conclusion'
required: false
output:
description: 'the output of your check'
required: false

Large diffs are not rendered by default.

@@ -14,17 +14,23 @@ const unpackInputs = (inputs: Inputs.Args): object => {
let output;
if (inputs.output) {
output = {
title: inputs.name,
summary: inputs.output.summary,
text: inputs.output.text_description,
actions: inputs.actions,
images: inputs.images,
};
}
const more: {details_url?: string} = {};
if (inputs.conclusion === Inputs.Conclusion.ActionRequired || inputs.actions) {
more.details_url = inputs.actionURL;
}
return {
status: inputs.status.toString(),
conclusion: inputs.conclusion.toString(),
output,
actions: inputs.actions,
...more,
};
};

@@ -20,7 +20,8 @@ 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}) as Inputs.Conclusion;
const conclusion = getInput('conclusion', {required: true}).toLowerCase() as Inputs.Conclusion;
const actionURL = getInput('action_url');

if (!Object.values(Inputs.Status).includes(status)) {
throw new Error(`invalid value for 'status': '${status}'`);
@@ -35,12 +36,22 @@ export const parseInputs = (getInput: GetInput): Inputs.Args => {
const images = parseJSON<Inputs.Images>(getInput, 'images');
const actions = parseJSON<Inputs.Actions>(getInput, 'actions');

if (!actionURL && (conclusion === Inputs.Conclusion.ActionRequired || actions)) {
throw new Error(`missing value for 'action_url'`);
}

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

return {
name,
token,
status,
conclusion,

actionURL,

output,
annotations,
images,
@@ -5,6 +5,9 @@ export type Args = {
token: string;
conclusion: Conclusion;
status: Status;

actionURL: string;

output?: Output;
annotations?: Annotations;
images?: Images;

0 comments on commit 297d38e

Please sign in to comment.