Skip to content

Commit a4e3ff8

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/git-for-windows/git-for-windows-automation/actions/runs?actor='gitforwindowshelper[bot]&event=workflow_dispatch&created>=2026-01-15T12:00:00Z' | jq | grep created_at "created_at": "2026-01-15T22:18:14Z", "created_at": "2026-01-15T20:58:42Z", "created_at": "2026-01-15T12:42:57Z", "created_at": "2026-01-15T12:17:48Z", "created_at": "2026-01-15T12:17:45Z", "created_at": "2026-01-15T12:17:43Z", "created_at": "2026-01-15T12:12:21Z", "created_at": "2026-01-15T12:10:25Z", "created_at": "2026-01-15T12:01:04Z", "created_at": "2026-01-15T09:39:35Z", "created_at": "2026-01-14T13:56:33Z", "created_at": "2026-01-09T11:40:57Z", "created_at": "2026-01-08T18:49:18Z", "created_at": "2026-01-08T18:13:21Z", "created_at": "2026-01-07T21:09:24Z", "created_at": "2026-01-07T21:09:21Z", "created_at": "2026-01-07T21:09:17Z", "created_at": "2026-01-07T21:08:59Z", "created_at": "2026-01-07T09:00:34Z", "created_at": "2026-01-06T11:24:19Z", "created_at": "2026-01-04T09:26:02Z", "created_at": "2026-01-04T09:09:39Z", "created_at": "2025-12-24T17:41:56Z", "created_at": "2025-12-24T13:00:34Z", "created_at": "2025-12-04T17:14:59Z", "created_at": "2025-12-04T12:15:44Z", "created_at": "2025-12-01T16:49:29Z", "created_at": "2025-11-27T10:00:40Z", "created_at": "2025-11-25T22:24:46Z", "created_at": "2025-11-25T21:59:57Z", As you can see, it totally lists quite old runs, too. 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 81658e8 commit a4e3ff8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

GitForWindowsHelper/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, owner, repo, workflow_id, after, toke
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)