mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
`github.event.issue.pull_request` is an object, not a boolean. This is the root cause of why the step that is supposed to remove labels is always skipped. Having this condition in place is not necessary since the workflow is run on the `pull_request_target` event.
115 lines
4.1 KiB
YAML
115 lines
4.1 KiB
YAML
---
|
|
# vi: ts=2 sw=2 et:
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
#
|
|
name: "Pull Request Labeler"
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, synchronize, reopened, ready_for_review, closed]
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
triage:
|
|
if: github.repository == 'systemd/systemd'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
pull-requests: write
|
|
steps:
|
|
- uses: actions/labeler@e54e5b338fbd6e6cdb5d60f51c22335fc57c401e
|
|
if: github.event_name == 'pull_request_target' && github.event.action != 'closed'
|
|
with:
|
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
configuration-path: .github/labeler.yml
|
|
sync-labels: "" # This is a workaround for issue 18671
|
|
|
|
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
|
|
if: github.event_name == 'pull_request_target' && github.event.action != 'closed' && !github.event.pull_request.draft
|
|
with:
|
|
script: |
|
|
response = await github.rest.issues.listLabelsOnIssue({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
});
|
|
|
|
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"]
|
|
});
|
|
}
|
|
|
|
for (const label of ["reviewed/needs-rework 🔨",
|
|
"ci-fails/needs-rework 🔥",
|
|
"ci-failure-appears-unrelated",
|
|
"needs-rebase"]) {
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
|
|
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/please-review')
|
|
with:
|
|
script: |
|
|
await github.rest.issues.addLabels({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
labels: ["please-review"]
|
|
})
|
|
|
|
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
|
|
if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
|
|
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 ❓",
|
|
"dont-merge",
|
|
"squash-on-merge",
|
|
"quick-review"]) {
|
|
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;
|
|
}
|
|
}
|
|
}
|