Skip to content

Commit

Permalink
Workaround GH api break around filtering runs by status (#36)
Browse files Browse the repository at this point in the history
* Workaround GH api break around filtering runs by status

* Add missing assets

* Fix

* Built assets

* Fix
  • Loading branch information
viveklak committed May 4, 2023
1 parent 0f2cb5a commit 59bbf83
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 13 deletions.
23 changes: 21 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

38 changes: 28 additions & 10 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,34 @@ export async function run(opts: RunOpts): Promise<void> {

const workflow_id = String(current_run.workflow_id)
try {
const {
data: {workflow_runs}
} = await octokit.rest.actions.listWorkflowRuns({
per_page: 100,
owner,
repo,
workflow_id,
branch,
...(opts.status && {status: opts.status})
})
const workflow_runs = await octokit.paginate(
octokit.rest.actions.listWorkflowRuns,
{
per_page: 100,
owner,
repo,
workflow_id,
branch
},
(response, done) => {
let res = response.data.workflow_runs
if (opts.status) {
if (response.data.workflow_runs) {
res = response.data.workflow_runs.filter(
resp => resp.status === opts.status
)
} else {
res = []
}
}
// Don't actually want to look through all the runs - if we find some matching the status, lets return
//
if (res.length > 0) {
done()
}
return res
}
)

let lastCommit = ''
if (opts.limitToPreviousSuccessfulRunCommit) {
Expand Down

0 comments on commit 59bbf83

Please sign in to comment.