-
Notifications
You must be signed in to change notification settings - Fork 27
41 lines (39 loc) · 1.54 KB
/
auto-label-comment-prs.yml
File metadata and controls
41 lines (39 loc) · 1.54 KB
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
name: "Label PRs and auto-comment"
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
pr_label_comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr_number = context.payload.pull_request.number;
// Add label
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number,
labels: ["needs-review", "copilot"] // <-- TUNE ME
});
console.log(`✅ Added labels to PR #${pr_number}`);
} catch (error) {
console.log(`⚠️ Failed to add labels: ${error.message}`);
console.log("Note: This may be due to insufficient permissions or invalid label names.");
}
// Add automated comment
try {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number,
body: "Thanks for the PR! Copilot will assist with review."
});
console.log(`✅ Added comment to PR #${pr_number}`);
} catch (error) {
console.log(`⚠️ Failed to add comment: ${error.message}`);
console.log("Note: This may be due to insufficient permissions.");
}