workflows/labels: fix first scheduled run

This would fail, because no previous workflow can be found.

(cherry picked from commit 4425979533)
This commit is contained in:
Wolfgang Walther
2025-06-16 15:55:40 +02:00
parent b4635611fa
commit f1fa19034f

View File

@@ -69,13 +69,14 @@ jobs:
// Normally a scheduled run, but could be workflow_dispatch, see above. Go back as far
// as the last successful run of this workflow to make sure we are not leaving anyone
// behind on GHA failures.
// Defaults to go back 1 hour on the first run.
return (await github.rest.actions.listWorkflowRuns({
...context.repo,
workflow_id: 'labels.yml',
event: 'schedule',
status: 'success',
exclude_pull_requests: true
})).data.workflow_runs[0]?.created_at
})).data.workflow_runs[0]?.created_at ?? new Date().getTime() - 1 * 60 * 60 * 1000
})())
core.info('cutoff timestamp: ' + cutoff.toISOString())