Skip to content

Commit 788970d

Browse files
Merge pull request #9 from pytorch-fdn/reginankenchor-patch-6
Create auto-update-labels.yml
2 parents 04d1a56 + f99f70b commit 788970d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Auto-Update Nomination Status Labels"
2+
on:
3+
issue_comment:
4+
types: [created]
5+
6+
jobs:
7+
update-labels:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check Comment and Update Labels
11+
uses: actions/github-script@v6
12+
with:
13+
github-token: ${{ secrets.GITHUB_TOKEN }}
14+
script: |
15+
const issue = context.payload.issue;
16+
const comment = context.payload.comment.body.toLowerCase();
17+
const repoOwner = context.repo.owner;
18+
const repoName = context.repo.repo;
19+
const issueNumber = issue.number;
20+
21+
let newLabel = null;
22+
23+
if (comment.includes("approved")) {
24+
newLabel = "approved";
25+
} else if (comment.includes("rejected")) {
26+
newLabel = "rejected";
27+
} else if (comment.includes("needs more info")) {
28+
newLabel = "needs-more-info";
29+
}
30+
31+
if (newLabel) {
32+
await github.rest.issues.update({
33+
owner: repoOwner,
34+
repo: repoName,
35+
issue_number: issueNumber,
36+
labels: [newLabel]
37+
});
38+
39+
console.log(`Updated issue #${issueNumber} with label: ${newLabel}`);
40+
}

0 commit comments

Comments
 (0)