This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airflow-checks-action.git
commit 297d38e67227bd87efedf3ad97cce96b180777a5 Author: Louis Brunner <[email protected]> AuthorDate: Sat Feb 29 22:02:22 2020 +0000 Fix build pipeline --- .github/workflows/examples.yml | 33 +++++++++++++++++---------------- action.yml | 3 +++ dist/index.js | 2 +- src/checks.ts | 6 ++++++ src/inputs.ts | 13 ++++++++++++- src/namespaces/Inputs.ts | 3 +++ 6 files changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 301e1d0..b970e6f 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -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 }} diff --git a/action.yml b/action.yml index 125221d..3310b94 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/dist/index.js b/dist/index.js index c5a551b..5b4f331 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var i=r[t]={i:t,l:false,exports:{}};e[t].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(198)}return startup()}({0:function(e,t,r){const{requestLog:i}=r(916);const{restEndpointMethods:n}=r(842);const s=r(529);const o=[r(190),r(19),i,r(148),n,r(430),r(850)];const a=s.plug [...] \ No newline at end of file +module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var i=r[t]={i:t,l:false,exports:{}};e[t].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(198)}return startup()}({0:function(e,t,r){const{requestLog:i}=r(916);const{restEndpointMethods:n}=r(842);const s=r(529);const o=[r(190),r(19),i,r(148),n,r(430),r(850)];const a=s.plug [...] \ No newline at end of file diff --git a/src/checks.ts b/src/checks.ts index 8271217..7b34ad5 100644 --- a/src/checks.ts +++ b/src/checks.ts @@ -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, }; }; diff --git a/src/inputs.ts b/src/inputs.ts index c2e734e..5c84542 100644 --- a/src/inputs.ts +++ b/src/inputs.ts @@ -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, diff --git a/src/namespaces/Inputs.ts b/src/namespaces/Inputs.ts index 9bfcba3..d4ff931 100644 --- a/src/namespaces/Inputs.ts +++ b/src/namespaces/Inputs.ts @@ -5,6 +5,9 @@ export type Args = { token: string; conclusion: Conclusion; status: Status; + + actionURL: string; + output?: Output; annotations?: Annotations; images?: Images;
