summaryrefslogtreecommitdiffstats
path: root/.github/workflows/labeler.yml
blob: 952bcbfbedc9b5e1af51c7640b69ca55d60acab8 (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
65
66
67
68
69
70
71
72
73
name: 'Pull Request Labeler'
on:
  pull_request_target:

permissions:
  contents: read
  pull-requests: write

jobs:
  labeler:
    name: Pull Request Labeler
    runs-on: ubuntu-slim
    steps:
      - uses: actions/labeler@v6
        with:
          repo-token: '${{ secrets.GITHUB_TOKEN }}'
          sync-labels: true

      - name: Checkout PR code
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          fetch-depth: 0

      - name: Fetch base
        run: git fetch origin ${{ github.event.pull_request.base.sha }}

      - name: Check for PKG_VERSION changes
        id: check_version
        # Check for new packages (any Makefile with status 'A' - Added)
        # Check for dropped packages (any Makefile with status 'D' - Deleted)
        run: |
          if git diff --name-only --diff-filter=A "${{ github.event.pull_request.base.sha }}"...HEAD -- '**/Makefile' | grep -q .; then
            echo "New package detected."
            echo "new_package=true" >> $GITHUB_OUTPUT
          fi

          if git diff --name-only --diff-filter=D "${{ github.event.pull_request.base.sha }}"...HEAD -- '**/Makefile' | grep -q .; then
            echo "Dropped package detected."
            echo "dropped_package=true" >> $GITHUB_OUTPUT
          fi

      - name: Add 'Add package' label
        if: steps.check_version.outputs.new_package == 'true'
        uses: buildsville/add-remove-label@v2.0.1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          labels: "Add package"
          type: add

      - name: Remove 'Add package' label
        if: steps.check_version.outputs.new_package != 'true'
        uses: buildsville/add-remove-label@v2.0.1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          labels: "Add package"
          type: remove

      - name: Add 'Drop package' label
        if: steps.check_version.outputs.dropped_package == 'true'
        uses: buildsville/add-remove-label@v2.0.1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          labels: "Drop package"
          type: add

      - name: Remove 'Drop package' label
        if: steps.check_version.outputs.dropped_package != 'true'
        uses: buildsville/add-remove-label@v2.0.1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          labels: "Drop package"
          type: remove