From 6f535a4a2ce6b9a92df42da8c2fffe360d1a4436 Mon Sep 17 00:00:00 2001 From: Shigure Kurosaki Date: Sun, 29 Dec 2024 19:55:22 +0800 Subject: [PATCH] chore: Added handling for nonexistent labels in labeler.yml and removed the permission to add labels from dependabot.yml (#151) * chore: Added handling for nonexistent labels in labeler.yml and removed the permission to add labels from dependabot.yml * fix: Missing GH_TOKEN --- .github/dependabot.yml | 4 ++-- .github/workflows/labeler.yml | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1f57780..bdd41b1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,13 +5,13 @@ updates: schedule: interval: daily open-pull-requests-limit: 10 - labels: [ 'dependency' ] + labels: [ ] commit-message: prefix: 'dep' - package-ecosystem: github-actions directory: '/' schedule: interval: daily - labels: [ 'action' ] + labels: [ ] commit-message: prefix: 'act' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 9794f4f..bf482aa 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -46,3 +46,22 @@ jobs: if: ${{ startsWith(github.event.pull_request.title, 'test:') }} with: labels: test + - name: Add dependency label + uses: actions-ecosystem/action-add-labels@v1 + if: ${{ startsWith(github.event.pull_request.title, 'dep:') }} + with: + labels: dependency + - name: Add action label + uses: actions-ecosystem/action-add-labels@v1 + if: ${{ startsWith(github.event.pull_request.title, 'act:') }} + with: + labels: action + - name: Check if no label was added + run: | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') + if [ -z "$labels" ]; then + echo "No labels were added, closing the pull request." + gh pr close ${{ github.event.pull_request.number }} --comment "Closing PR: No valid prefix found in the title." + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}