···
const approvals = new Set(
30
-
.filter((review) => review.state == 'APPROVED')
30
+
.filter((review) => review.state === 'APPROVED')
.map((review) => review.user?.id),
···
// This is intentionally less than the time that Eval takes, so that the label job
// running after Eval can indeed label the PR as conflicted if that is the case.
const merge_commit_sha_valid =
40
-
new Date() - new Date(pull_request.created_at) > 3 * 60 * 1000
40
+
Date.now() - new Date(pull_request.created_at) > 3 * 60 * 1000
// We intentionally don't use the mergeable or mergeable_state attributes.
···
// The second pass will then read the result from the first pass and set the label.
'2.status: merge conflict':
merge_commit_sha_valid && !pull_request.merge_commit_sha,
56
-
'12.approvals: 1': approvals.size == 1,
57
-
'12.approvals: 2': approvals.size == 2,
56
+
'12.approvals: 1': approvals.size === 1,
57
+
'12.approvals: 2': approvals.size === 2,
'12.approvals: 3+': approvals.size >= 3,
'12.first-time contribution': [
···
// existing reviews, too.
107
-
pull_request.requested_reviewers.length == 0 &&
108
-
reviews.length == 0,
107
+
pull_request.requested_reviewers.length === 0 &&
108
+
reviews.length === 0,
···
// called "comparison", yet, will skip the download.
128
-
new Date(artifact?.expires_at ?? 0) <
129
-
new Date(new Date().getTime() + 60 * 1000)
128
+
new Date(artifact?.expires_at ?? 0) < new Date(Date.now() + 60 * 1000)
log('Artifact expires at', artifact?.expires_at ?? '<n/a>')
···
async function handle({ item, stats }) {
const log = (k, v, skip) => {
178
-
core.info(`#${item.number} - ${k}: ${v}` + (skip ? ' (skipped)' : ''))
177
+
core.info(`#${item.number} - ${k}: ${v}${skip ? ' (skipped)' : ''}`)
···
// No need for an API request, if all labels are the same.
const hasChanges = Object.keys(after).some(
260
-
(name) => (before[name] ?? false) != after[name],
259
+
(name) => (before[name] ?? false) !== after[name],
if (log('Has changes', hasChanges, !hasChanges)) return
···
// we are not leaving anyone behind on GHA failures.
// Defaults to go back 1 hour on the first run.
301
-
lastRun?.created_at ?? new Date().getTime() - 1 * 60 * 60 * 1000,
300
+
lastRun?.created_at ?? Date.now() - 1 * 60 * 60 * 1000,
// Go back max. 1 day to prevent hitting all API rate limits immediately,
// when GH API returns a wrong workflow by accident.
305
-
new Date().getTime() - 24 * 60 * 60 * 1000,
304
+
Date.now() - 24 * 60 * 60 * 1000,
308
-
core.info('cutoff timestamp: ' + cutoff.toISOString())
307
+
core.info(`cutoff timestamp: ${cutoff.toISOString()}`)
const updatedItems = await github.paginate(
github.rest.search.issuesAndPullRequests,
···
.concat(updatedItems, allItems.data)
406
-
arr.findIndex((firstItem) => firstItem.number == thisItem.number),
405
+
arr.findIndex((firstItem) => firstItem.number === thisItem.number),
;(await Promise.allSettled(items.map((item) => handle({ item, stats }))))
410
-
.filter(({ status }) => status == 'rejected')
409
+
.filter(({ status }) => status === 'rejected')
core.setFailed(`${reason.message}\n${reason.cause.stack}`),