Skip to content

Commit 692ffc9

Browse files
committed
feat: enhance permissions and error handling in PR labeler workflow
1 parent 0698f5c commit 692ffc9

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

.github/workflows/labeler.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,36 @@ jobs:
1111
labeler:
1212
name: Label Pull Request
1313
runs-on: ubuntu-latest
14-
# Only this job needs specific permissions
14+
# Enhanced permissions for label management
1515
permissions:
1616
contents: read # Required to check out the code
1717
pull-requests: write # Required to apply labels to PRs
18+
issues: write # Required to create and manage labels
19+
repository-projects: write # Required for repository management
1820
steps:
1921
- name: Harden the runner (Audit all outbound calls)
2022
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
2123
with:
2224
egress-policy: audit
2325

26+
- name: Checkout repository
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
fetch-depth: 1
31+
2432
- name: Apply PR Labels
2533
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
2634
with:
2735
repo-token: "${{ secrets.GITHUB_TOKEN }}"
28-
sync-labels: true
36+
sync-labels: false # Don't sync labels to avoid permission issues
2937
configuration-path: .github/labeler.yml
38+
dot: true # Enable dotfiles processing
39+
continue-on-error: true # Continue even if some labels can't be created
40+
41+
- name: Label creation status
42+
if: failure()
43+
run: |
44+
echo "⚠️ Some labels could not be applied due to permissions."
45+
echo "This is expected for repositories where label creation is restricted."
46+
echo "Labels can be manually created or the repository permissions can be adjusted."

0 commit comments

Comments
 (0)