mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
workflow/labels: save an API request
With the previous commit we now have the `before` labels available
already, which allows some simplification.
(cherry picked from commit 4d537009c6)
This commit is contained in:
committed by
github-actions[bot]
parent
b17cc5ba4a
commit
aefa2d1d8b
18
.github/workflows/labels.yml
vendored
18
.github/workflows/labels.yml
vendored
@@ -140,16 +140,9 @@ jobs:
|
||||
expectedHash: artifact.digest
|
||||
})
|
||||
|
||||
// Shortcut for all issue endpoints related to labels
|
||||
const pr = {
|
||||
...context.repo,
|
||||
issue_number: pull_request.number
|
||||
}
|
||||
|
||||
// Get all currently set labels that we manage
|
||||
const before =
|
||||
(await github.paginate(github.rest.issues.listLabelsOnIssue, pr))
|
||||
.map(({ name }) => name)
|
||||
pull_request.labels.map(({ name }) => name)
|
||||
.filter(name =>
|
||||
name.startsWith('10.rebuild') ||
|
||||
name == '11.by: package-maintainer' ||
|
||||
@@ -159,8 +152,7 @@ jobs:
|
||||
|
||||
const approvals = new Set(
|
||||
(await github.paginate(github.rest.pulls.listReviews, {
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
...context.repo,
|
||||
pull_number: pull_request.number
|
||||
}))
|
||||
.filter(review => review.state == 'APPROVED')
|
||||
@@ -180,7 +172,8 @@ jobs:
|
||||
await Promise.all(
|
||||
before.filter(name => !after.includes(name))
|
||||
.map(name => github.rest.issues.removeLabel({
|
||||
...pr,
|
||||
...context.repo,
|
||||
issue_number: pull_request.number
|
||||
name
|
||||
}))
|
||||
)
|
||||
@@ -189,7 +182,8 @@ jobs:
|
||||
const added = after.filter(name => !before.includes(name))
|
||||
if (added.length > 0) {
|
||||
await github.rest.issues.addLabels({
|
||||
...pr,
|
||||
...context.repo,
|
||||
issue_number: pull_request.number
|
||||
labels: added
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user