2021-10-01 13:09:20 +03:00
---
# vi: ts=2 sw=2 et:
2021-10-01 13:10:22 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2021-10-01 13:09:20 +03:00
#
2020-12-12 09:30:26 +03:00
name : "Pull Request Labeler"
2021-10-01 13:09:20 +03:00
2020-12-12 09:30:26 +03:00
on :
2022-12-09 14:10:09 +03:00
pull_request_target :
2023-01-10 15:16:33 +03:00
types : [ opened, synchronize, reopened, ready_for_review, closed]
2022-12-09 14:10:09 +03:00
issue_comment :
types : [ created]
2020-12-12 09:30:26 +03:00
2021-11-13 17:40:20 +03:00
permissions :
contents : read
2020-12-12 09:30:26 +03:00
jobs :
triage :
2022-12-09 14:10:09 +03:00
if : github.repository == 'systemd/systemd'
2020-12-12 09:30:26 +03:00
runs-on : ubuntu-latest
2021-11-14 12:41:42 +03:00
permissions :
pull-requests : write
2023-02-08 15:02:49 +03:00
2020-12-12 09:30:26 +03:00
steps :
2023-02-08 15:02:49 +03:00
- name : Label PR based on policy in labeler.yml
2023-08-01 12:03:30 +03:00
uses : actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594
2023-01-12 13:11:12 +03:00
if : github.event_name == 'pull_request_target' && github.event.action != 'closed'
2020-12-12 09:30:26 +03:00
with :
repo-token : "${{ secrets.GITHUB_TOKEN }}"
configuration-path : .github/labeler.yml
2021-02-19 08:28:20 +03:00
sync-labels : "" # This is a workaround for issue 18671
2022-12-08 18:25:03 +03:00
2023-02-08 15:02:49 +03:00
- name : Set or remove labels based on systemd development workflow
2023-05-01 12:57:30 +03:00
uses : actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
2023-01-12 13:11:12 +03:00
if : github.event_name == 'pull_request_target' && github.event.action != 'closed' && !github.event.pull_request.draft
2022-12-08 18:25:03 +03:00
with :
script : |
2022-12-09 14:10:09 +03:00
response = await github.rest.issues.listLabelsOnIssue({
2022-12-08 18:25:03 +03:00
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
2022-12-09 14:10:09 +03:00
});
good_to_merge = [
"good-to-merge/waiting-for-ci 👍" ,
"good-to-merge/after-next-release" ,
"good-to-merge/with-minor-suggestions" ,
"good-to-merge/waiting-for-reporter-feedback 👍" ,
] ;
if (response.data.every(l => !good_to_merge.includes(l.name))) {
await github.rest.issues.addLabels({
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
labels : [ "please-review" ]
});
}
2022-12-08 18:25:03 +03:00
for (const label of ["reviewed/needs-rework 🔨",
"ci-fails/needs-rework 🔥" ,
2022-12-09 14:10:09 +03:00
"ci-failure-appears-unrelated" ,
"needs-rebase" ] ) {
2022-12-08 18:25:03 +03:00
try {
await github.rest.issues.removeLabel({
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
name : label,
2022-12-09 14:10:09 +03:00
});
2022-12-08 18:25:03 +03:00
} catch (err) {
if (err.status != 404) {
throw err;
}
}
}
2023-02-08 15:02:49 +03:00
- name : Add please-review label on command in issue comment
2023-05-01 12:57:30 +03:00
uses : actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
2022-12-08 18:25:03 +03:00
if : github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/please-review')
with :
script : |
2022-12-09 14:10:09 +03:00
await github.rest.issues.addLabels({
2022-12-08 18:25:03 +03:00
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
labels : [ "please-review" ]
})
2023-01-10 15:16:33 +03:00
2023-02-08 15:02:49 +03:00
- name : Remove specific labels when PR is closed or merged
2023-05-01 12:57:30 +03:00
uses : actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
2023-02-07 17:40:47 +03:00
if : github.event_name == 'pull_request_target' && github.event.action == 'closed'
2023-01-10 15:16:33 +03:00
with :
script : |
for (const label of ["please-review",
"reviewed/needs-rework 🔨" ,
"ci-fails/needs-rework 🔥" ,
"needs-rebase" ,
"good-to-merge/waiting-for-ci 👍" ,
"good-to-merge/after-next-release" ,
"good-to-merge/with-minor-suggestions" ,
"good-to-merge/waiting-for-reporter-feedback 👍" ,
"needs-discussion 🤔" ,
"needs-reporter-feedback ❓" ,
2023-02-11 09:38:28 +03:00
"dont-merge 💣" ,
2023-02-07 17:39:37 +03:00
"squash-on-merge" ,
2023-02-11 09:35:07 +03:00
"quick-review 🏃♂️" ] ) {
2023-01-10 15:16:33 +03:00
try {
await github.rest.issues.removeLabel({
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
name : label,
});
} catch (err) {
if (err.status != 404) {
throw err;
}
}
}