From 89eae88af273ccb9aaeaadcd479c2c8d7f1337c6 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 4 Aug 2021 22:03:00 +0200 Subject: [PATCH 1/8] main: throw if no runID --- main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 1e141c3c..e00d3642 100644 --- a/main.js +++ b/main.js @@ -83,7 +83,11 @@ async function main() { } } - console.log("==> RunID:", runID) + if (runID) { + console.log("==> RunID:", runID) + } else { + throw new Error("no matching workflow run found") + } let artifacts = await client.paginate(client.actions.listWorkflowRunArtifacts, { owner: owner, From e2532ee40db133c2b023b0f1e73c387bdb5b9724 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 4 Aug 2021 22:06:31 +0200 Subject: [PATCH 2/8] action: only success --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 0c27e9d6..ac2a779b 100644 --- a/action.yml +++ b/action.yml @@ -14,11 +14,11 @@ inputs: required: true workflow_conclusion: description: | - Wanted status or conclusion or both to search for in recent runs + Wanted status or conclusion to search for in recent runs https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs required: false - default: completed,success + default: success repo: description: Repository name with owner (like actions/checkout) required: false From e9886c91beefaecd5bf17afc99bbbb84080baeff Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 4 Aug 2021 22:11:08 +0200 Subject: [PATCH 3/8] README: update --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3dd4157..0ec0f21a 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,10 @@ Let's suppose you have a workflow with a job in it that at the end uploads an ar # Required, workflow file name or ID workflow: workflow_name.yml # Optional, the status or conclusion of a completed workflow to search for - # Can be one of a workflow conclusion:: - # "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required" + # Can be one of a workflow conclusion: + #. "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required" # Or a workflow status: - # "completed", "in_progress", "queued" - # Default: "completed,success" + # "completed", "in_progress", "queued" workflow_conclusion: success # Optional, will get head commit SHA pr: ${{github.event.pull_request.number}} From 04e29e0066cc0c4c504af05de1e8423741364712 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 4 Aug 2021 22:14:38 +0200 Subject: [PATCH 4/8] workflows: test empty conclusion --- .github/workflows/download.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/download.yml b/.github/workflows/download.yml index 4f09b1b0..41f441ca 100644 --- a/.github/workflows/download.yml +++ b/.github/workflows/download.yml @@ -84,6 +84,6 @@ jobs: workflow: upload.yml name: artifact path: artifact - workflow_conclusion: success + workflow_conclusion: '' - name: Test run: cat artifact/sha | grep $GITHUB_SHA From 65cb3507478be412fd72f74df6756e526bdb3aaa Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 4 Aug 2021 21:00:20 +0100 Subject: [PATCH 5/8] ADDED: Fix for octo weirdness --- main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index e00d3642..9586acca 100644 --- a/main.js +++ b/main.js @@ -12,7 +12,7 @@ async function main() { const [owner, repo] = core.getInput("repo", { required: true }).split("/") const path = core.getInput("path", { required: true }) const name = core.getInput("name") - let workflowConclusion = core.getInput("workflow_conclusion") + let workflowConclusion = core.getInput("workflow_conclusion").split(",").map(o => o.trim()) let pr = core.getInput("pr") let commit = core.getInput("commit") let branch = core.getInput("branch") @@ -63,7 +63,6 @@ async function main() { workflow_id: workflow, branch: branch, event: event, - status: workflowConclusion, } )) { const run = runs.data.find(r => { @@ -73,6 +72,9 @@ async function main() { if (runNumber) { return r.run_number == runNumber } + if (workflowConclusion.length > 0) { + return workflowConclusion.includes(r.status) || workflowConclusion.includes(r.conclusion) + } return true }) From dd7a2e8f02d7f0e6a02e2e3e68903aa2e172e9ed Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 4 Aug 2021 21:10:44 +0100 Subject: [PATCH 6/8] UPDATED: Put default in there --- main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/main.js b/main.js index 9586acca..a87cbeed 100644 --- a/main.js +++ b/main.js @@ -13,6 +13,7 @@ async function main() { const path = core.getInput("path", { required: true }) const name = core.getInput("name") let workflowConclusion = core.getInput("workflow_conclusion").split(",").map(o => o.trim()) + if (workflowConclusion.length == 0) workflowConclusion = ["completed","success"] let pr = core.getInput("pr") let commit = core.getInput("commit") let branch = core.getInput("branch") From 5f1493525bcaf0047095ade2d6d43f20c2b3b544 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 4 Aug 2021 22:33:01 +0200 Subject: [PATCH 7/8] Update main.js --- main.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/main.js b/main.js index a87cbeed..054e05cf 100644 --- a/main.js +++ b/main.js @@ -12,8 +12,7 @@ async function main() { const [owner, repo] = core.getInput("repo", { required: true }).split("/") const path = core.getInput("path", { required: true }) const name = core.getInput("name") - let workflowConclusion = core.getInput("workflow_conclusion").split(",").map(o => o.trim()) - if (workflowConclusion.length == 0) workflowConclusion = ["completed","success"] + let workflowConclusion = core.getInput("workflow_conclusion") let pr = core.getInput("pr") let commit = core.getInput("commit") let branch = core.getInput("branch") @@ -66,23 +65,22 @@ async function main() { event: event, } )) { - const run = runs.data.find(r => { - if (commit) { - return r.head_sha == commit + for (const run of runs.data) { + if (commit && run.head_sha != commit) { + continue } - if (runNumber) { - return r.run_number == runNumber + if (runNumber && run.run_number != runNumber) { + continue } - if (workflowConclusion.length > 0) { - return workflowConclusion.includes(r.status) || workflowConclusion.includes(r.conclusion) + if (workflowConclusion && (workflowConclusion != run.conclusion || workflowConclusion != run.status)) { + continue } - return true - }) - - if (run) { runID = run.id break } + if (runID) { + break + } } } From 45425fc8c2b43762a938bdc8a865a073901b0cf0 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 4 Aug 2021 23:08:58 +0200 Subject: [PATCH 8/8] fix --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 054e05cf..738ea408 100644 --- a/main.js +++ b/main.js @@ -72,7 +72,7 @@ async function main() { if (runNumber && run.run_number != runNumber) { continue } - if (workflowConclusion && (workflowConclusion != run.conclusion || workflowConclusion != run.status)) { + if (workflowConclusion && (workflowConclusion != run.conclusion && workflowConclusion != run.status)) { continue } runID = run.id