summaryrefslogtreecommitdiff
path: root/.github/workflows/labeler.yml
blob: b86d1ff7692cf638e4c5253d3f98ed7363eab2bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
# vi: ts=2 sw=2 et:
# SPDX-License-Identifier: LGPL-2.1-or-later
#
name: "Pull Request Labeler"

on:
- pull_request_target
- issue_comment

permissions:
  contents: read

jobs:
  triage:
    if: github.event.repository.name != 'systemd-security'
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
    - uses: actions/labeler@e54e5b338fbd6e6cdb5d60f51c22335fc57c401e
      if: github.event_name == 'pull_request_target'
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
        configuration-path: .github/labeler.yml
        sync-labels: "" # This is a workaround for issue 18671

    - uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0
      if: github.event_name == 'pull_request_target'
      with:
        script: |
          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"]) {
            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@d556feaca394842dc55e4734bf3bb9f685482fa0
      if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/please-review')
      with:
        script: |
          github.rest.issues.addLabels({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            labels: ["please-review"]
          })