ci: add more labels
authorGeorge Sapkin <george@sapk.in>
Thu, 11 Dec 2025 15:19:50 +0000 (17:19 +0200)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Sun, 14 Dec 2025 09:44:48 +0000 (10:44 +0100)
Add 'Add package' label when a new Makefile is added or 'Drop package'
when a Makefile is deleted.

Label PRs to OpenWrt 25.12 branch.

Label CI-related PRs.

Signed-off-by: George Sapkin <george@sapk.in>
.github/labeler.yml
.github/workflows/labeler.yml

index 749cf3e497658fd7645c69f0fb60d66d53635677..ed3168fecbe6d9028f9fcc00821b79164928a1a8 100644 (file)
@@ -1,3 +1,9 @@
+# GitHub/CI
+"GitHub/CI":
+- changed-files:
+  - any-glob-to-any-file:
+    - ".github/**"
+
 # branches
 "OpenWrt 23.05 (end of support)":
 - base-branch:
@@ -5,3 +11,6 @@
 "OpenWrt 24.10":
 - base-branch:
   - "openwrt-24.10"
+"OpenWrt 25.12":
+- base-branch:
+  - "openwrt-25.12"
index dc6a480fd3e1452a9e299abad2534ae34daa971a..29fa3ac0295d90bdc0aa141fcf25bca7074971f4 100644 (file)
@@ -1,6 +1,6 @@
 name: 'Pull Request Labeler'
 on:
-  - pull_request_target
+  pull_request_target:
 
 permissions:
   contents: read
@@ -8,10 +8,6 @@ permissions:
 
 jobs:
   labeler:
-    permissions:
-      contents: read
-      pull-requests: write
-
     name: Pull Request Labeler
     runs-on: ubuntu-slim
     steps:
@@ -19,3 +15,59 @@ jobs:
         with:
           repo-token: '${{ secrets.GITHUB_TOKEN }}'
           sync-labels: true
+
+      - name: Checkout PR code
+        uses: actions/checkout@v5
+        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