Skip to content

Commit 70ed7ee

Browse files
authored
Workflow which removes 'Status: Waiting for Author' labels (#2795)
... when the author respons. Also adds a 'Waiting for Review' label afterwards.
1 parent f808909 commit 70ed7ee

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/labels.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Update Status Labels When Author Replies
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
11+
jobs:
12+
update_status_labels:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Update labels if author replies
17+
uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const waitingForAuthor = "Status: Waiting for Author";
21+
const waitingForReview = "Status: Waiting for Review";
22+
23+
const issue = context.payload.issue;
24+
const comment = context.payload.comment;
25+
26+
// Ignore bot comments
27+
if (comment.user.type === "Bot") {
28+
console.log("Ignoring bot comment.");
29+
return;
30+
}
31+
32+
// Only act if the comment author is the issue/PR author
33+
if (issue.user.login !== comment.user.login) {
34+
console.log("Comment is not from the author — doing nothing.");
35+
return;
36+
}
37+
38+
// Get existing labels
39+
const currentLabels = issue.labels.map(l => l.name);
40+
41+
// Check if "Status: Waiting for Author" is present
42+
const hasWaitingForAuthor = currentLabels.includes(waitingForAuthor);
43+
44+
if (!hasWaitingForAuthor) {
45+
console.log(`No "${waitingForAuthor}" label — nothing to remove.`);
46+
return;
47+
}
48+
49+
// Remove "Status: Waiting for Author"
50+
await github.rest.issues.removeLabel({
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
issue_number: issue.number,
54+
name: waitingForAuthor
55+
});
56+
console.log(`Removed "${waitingForAuthor}" label from #${issue.number}`);
57+
58+
// Add "Status: Waiting for Review" if not already present
59+
const hasWaitingForReview = currentLabels.includes(waitingForReview);
60+
if (!hasWaitingForReview) {
61+
await github.rest.issues.addLabels({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
issue_number: issue.number,
65+
labels: [waitingForReview]
66+
});
67+
console.log(`Added "${waitingForReview}" label to #${issue.number}`);
68+
} else {
69+
console.log(`"${waitingForReview}" already present — not adding again.`);
70+
}

0 commit comments

Comments
 (0)