Skip to content

Commit 2c933ff

Browse files
committed
Stop trusting GitHub's Action runs filtering by date
In 1ff8966 (Hot fix: accommodate for (silent?) change in GitHub API's condition parsing, 2026-01-15), I tried to address a bug that led to "timeouts" left and right, due to the `created=>${after}` filter not working as it used to: The corresponding GitHub API call to list all the recent workflow runs would always return 0 matches. To fix that, I replaced the `=>` operator with the `>=` operator. With that operator, the API calls finally returns a non-empty result. What I failed to anticipate was that the result is completely wrong. You are forgiven if you think, like I did, that the `created>=${after}` filter would only return recent runs, as documented here: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs-for-a-repository However, this is absolutely, positively not the case. See here: $ gh api \ repos/gitgitgadget-workflows/gitgitgadget-workflows/actions/runs?actor='gitgitgadget[bot]&event=workflow_dispatch&created>=2030-01-01T00:00:00Z' |r jq | grep created_at "created_at": "2026-01-16T07:32:45Z", "created_at": "2026-01-16T07:00:21Z", "created_at": "2026-01-16T05:43:30Z", "created_at": "2026-01-16T03:02:06Z", "created_at": "2026-01-16T00:58:29Z", "created_at": "2026-01-15T23:23:06Z", "created_at": "2026-01-15T23:17:48Z", "created_at": "2026-01-15T22:45:12Z", "created_at": "2026-01-15T22:24:25Z", "created_at": "2026-01-15T22:21:36Z", "created_at": "2026-01-15T21:46:03Z", "created_at": "2026-01-15T21:29:47Z", "created_at": "2026-01-15T20:59:06Z", "created_at": "2026-01-15T20:47:15Z", "created_at": "2026-01-15T20:47:12Z", "created_at": "2026-01-15T20:47:09Z", "created_at": "2026-01-15T20:46:01Z", "created_at": "2026-01-15T20:23:07Z", "created_at": "2026-01-15T19:54:58Z", "created_at": "2026-01-15T18:52:06Z", "created_at": "2026-01-15T18:41:08Z", "created_at": "2026-01-15T18:37:41Z", "created_at": "2026-01-15T18:37:38Z", "created_at": "2026-01-15T18:37:35Z", "created_at": "2026-01-15T18:37:33Z", "created_at": "2026-01-15T18:03:28Z", "created_at": "2026-01-15T17:44:43Z", "created_at": "2026-01-15T17:37:38Z", "created_at": "2026-01-15T17:37:30Z", "created_at": "2026-01-15T17:37:27Z", As you can see, despite the cut-off that is waaaay in the future, it totally lists recent runs. Work around that by distrusting the results returned from that GitHub API call and manually filtering out the too-old runs. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 3b7027b commit 2c933ff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

GitGitGadget/trigger-workflow-dispatch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const waitForWorkflowRun = async (context, token, owner, repo, workflow_id, afte
2828
'GET',
2929
`/repos/${owner}/${repo}/actions/runs?actor=${actor}&event=workflow_dispatch&created>=${after}`
3030
)
31-
const filtered = res.workflow_runs.filter(e => e.path === `.github/workflows/${workflow_id}`)
31+
const filtered = res.workflow_runs.filter(e => e.path === `.github/workflows/${workflow_id}` && after.localeCompare(e.created_at) <= 0)
3232
if (filtered.length > 0) return filtered
3333
if (counter++ > 30) throw new Error(`Times out waiting for workflow?`)
3434
await sleep(1000)

0 commit comments

Comments
 (0)