Skip to content

Commit 1526f29

Browse files
committed
chore: refactor spam labels (#2129)
Signed-off-by: Ajay Rajera <newajay.11r@gmail.com>
1 parent ef05dd4 commit 1526f29

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

.github/scripts/update-spam-list.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ const fs = require('fs').promises;
1212
const SPAM_LIST_PATH = '.github/spam-list.txt';
1313
const dryRun = (process.env.DRY_RUN || 'false').toString().toLowerCase() === 'true';
1414

15+
/**
16+
* These constants control the GitHub label names used by the spam automation.
17+
* To rename labels, update only the constant values here.
18+
* Ensure corresponding labels exist in the GitHub repository settings.
19+
*/
20+
const LABEL_SPAM = 'notes: spam';
21+
const LABEL_SPAM_LIST_UPDATE = 'notes: spam-list-update';
22+
1523
// Load current spam list and compute updates based on spam vs rehabilitated users
1624

1725
async function computeSpamListUpdates(spamUsers, rehabilitatedUsers) {
@@ -121,7 +129,7 @@ module.exports = async ({github, context, core}) => {
121129
const searches = [
122130
{
123131
name: 'spam PRs',
124-
query: `repo:${owner}/${repo} is:pr is:closed -is:merged label:spam`,
132+
query: `repo:${owner}/${repo} is:pr is:closed -is:merged label:"${LABEL_SPAM}"`,
125133
process: async (pr) => {
126134
if (!pr.user?.login) {
127135
console.log(`Skipping PR #${pr.number}: user account unavailable`);
@@ -208,7 +216,7 @@ module.exports = async ({github, context, core}) => {
208216
const { data: existing } = await github.rest.issues.listForRepo({
209217
owner,
210218
repo,
211-
labels: 'spam-list-update',
219+
labels: LABEL_SPAM_LIST_UPDATE,
212220
state: 'open',
213221
per_page: 1
214222
});
@@ -221,7 +229,7 @@ module.exports = async ({github, context, core}) => {
221229
repo,
222230
title,
223231
body,
224-
labels: ['spam-list-update', 'automated']
232+
labels: [LABEL_SPAM_LIST_UPDATE, 'automated']
225233
});
226234
console.log('Issue created successfully');
227235
}

0 commit comments

Comments
 (0)