Skip to content

Commit 0c544b3

Browse files
authored
Add permission for pr-label github actions (#22481)
* Add permission for pr-label github actions * Add permission for pr-label github actions * Add permission for pr-label github actions * Add permission for pr-label github actions
1 parent 5af6ca5 commit 0c544b3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.github/workflows/pr-labeled.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ env:
44
GH_TOKEN: ${{ github.token }}
55
PR: ${{ github.event.pull_request.html_url }}
66
on:
7-
pull_request:
7+
pull_request_target:
88
types:
99
- labeled
1010
jobs:
1111
process_labels:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: write
15+
contents: read
1316
steps:
1417
- uses: actions/checkout@v3
1518
with:

.github/workflows/script/PrLabeled.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ if ($CommentDict.ContainsKey($LabelName)) {
6060
Write-Host "Comment is already added"
6161
}
6262
else {
63-
gh pr comment $PrUrl --body $comment
63+
try {
64+
gh pr comment $PrUrl --body $comment
65+
}
66+
catch {
67+
Write-Host "Failed to add comment: $_"
68+
}
6469
}
6570
}

0 commit comments

Comments
 (0)