workflow/labels: fix scheduled runs (#417250)

This commit is contained in:
Wolfgang Walther 2025-06-16 15:08:48 +00:00 committed by GitHub
commit e1a3aac6ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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())
@ -98,7 +99,8 @@ jobs:
direction: 'desc',
...prEventCondition
},
async (response, done) => await Promise.all(response.data.map(async (pull_request) => {
async (response, done) => (await Promise.allSettled(response.data.map(async (pull_request) => {
try {
const log = (k,v) => core.info(`PR #${pull_request.number} - ${k}: ${v}`)
log('Last updated at', pull_request.updated_at)
@ -136,7 +138,7 @@ jobs:
repositoryOwner: context.repo.owner,
token: core.getInput('github-token')
},
path: path.resolve('comparison'),
path: path.resolve(pull_request.number.toString()),
expectedHash: artifact.digest
})
@ -160,11 +162,11 @@ jobs:
)
const maintainers = new Set(Object.keys(
JSON.parse(await readFile('comparison/maintainers.json', 'utf-8'))
JSON.parse(await readFile(`${pull_request.number}/maintainers.json`, 'utf-8'))
))
// And the labels that should be there
const after = JSON.parse(await readFile('comparison/changed-paths.json', 'utf-8')).labels
const after = JSON.parse(await readFile(`${pull_request.number}/changed-paths.json`, 'utf-8')).labels
if (approvals.size > 0) after.push(`12.approvals: ${approvals.size > 2 ? '3+' : approvals.size}`)
if (Array.from(maintainers).some(m => approvals.has(m))) after.push('12.approved-by: package-maintainer')
@ -187,7 +189,12 @@ jobs:
labels: added
})
}
}))
} catch (cause) {
throw new Error(`Labeling PR #${pull_request.number} failed.`, { cause })
}
})))
.filter(({ status }) => status == 'rejected')
.map(({ reason }) => core.setFailed(`${reason.message}\n${reason.cause.stack}`))
)
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0