summaryrefslogtreecommitdiffstats
path: root/.github/workflows/labeler.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
commitfc53809803cd2bc2434e312b19a18fa36776da12 (patch)
treeb4b43bd6538f51965ce32856e9c053d0f90919c8 /.github/workflows/labeler.yml
parentAdding upstream version 255.5. (diff)
downloadsystemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz
systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '.github/workflows/labeler.yml')
-rw-r--r--.github/workflows/labeler.yml93
1 files changed, 54 insertions, 39 deletions
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
index 7f66a53..241b581 100644
--- a/.github/workflows/labeler.yml
+++ b/.github/workflows/labeler.yml
@@ -7,6 +7,14 @@ name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review, closed]
+ paths-ignore:
+ - '.github/labeler.yml'
+ - '.github/workflows/labeler.yml'
+ # Allow testing changes made to the labeler configuration
+ pull_request:
+ paths:
+ - '.github/labeler.yml'
+ - '.github/workflows/labeler.yml'
issue_comment:
types: [created]
@@ -16,22 +24,26 @@ permissions:
jobs:
triage:
if: github.repository == 'systemd/systemd'
- runs-on: ubuntu-latest
+ runs-on: ubuntu-24.04
permissions:
pull-requests: write
steps:
+ - name: Repository checkout
+ uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
+ if: github.event_name == 'pull_request'
+
- name: Label PR based on policy in labeler.yml
- uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594
- if: github.event_name == 'pull_request_target' && github.event.action != 'closed'
+ uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9
+ if: startsWith(github.event_name, 'pull_request') && github.event.action != 'closed'
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/labeler.yml
- sync-labels: "" # This is a workaround for issue 18671
+ sync-labels: false
- name: Set or remove labels based on systemd development workflow
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
- if: github.event_name == 'pull_request_target' && github.event.action != 'closed' && !github.event.pull_request.draft
+ if: startsWith(github.event_name, 'pull_request') && github.event.action != 'closed' && !github.event.pull_request.draft
with:
script: |
response = await github.rest.issues.listLabelsOnIssue({
@@ -40,38 +52,34 @@ jobs:
repo: context.repo.repo,
});
- good_to_merge = [
+ original = new Set(response.data.map(l => l.name));
+ labels = new Set(original);
+
+ good_to_merge = new Set([
"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"]
- });
+ if (Array.from(labels).filter(l => good_to_merge.has(l)).length == 0) {
+ labels.add("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;
- }
- }
+ labels.delete(label);
+ }
+
+ if (labels.size != original.size || Array.from(labels).some(l => !original.has(l))) {
+ await github.rest.issues.setLabels({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ labels: Array.from(labels),
+ });
}
- name: Add please-review label on command in issue comment
@@ -88,9 +96,18 @@ jobs:
- name: Remove specific labels when PR is closed or merged
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
- if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
+ if: startsWith(github.event_name, 'pull_request') && github.event.action == 'closed'
with:
script: |
+ response = await github.rest.issues.listLabelsOnIssue({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ });
+
+ original = new Set(response.data.map(l => l.name));
+ labels = new Set(original);
+
for (const label of ["please-review",
"reviewed/needs-rework 🔨",
"ci-fails/needs-rework 🔥",
@@ -104,16 +121,14 @@ jobs:
"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;
- }
- }
+ labels.delete(label);
+ }
+
+ if (labels.size != original.size || Array.from(labels).some(l => !original.has(l))) {
+ await github.rest.issues.setLabels({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ labels: Array.from(labels),
+ });
}