Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/scripts/cron-admin-update-spam-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const fs = require('fs').promises;
const SPAM_LIST_PATH = '.github/spam-list.txt';
const dryRun = (process.env.DRY_RUN || 'false').toString().toLowerCase() === 'true';

/**
* These constants control the GitHub label names used by the spam automation.
* To rename labels, update only the constant values here.
* Ensure corresponding labels exist in the GitHub repository settings.
*/
const LABEL_SPAM = 'notes: spam';
const LABEL_SPAM_LIST_UPDATE = 'notes: spam-list-update';

// Load current spam list and compute updates based on spam vs rehabilitated users

async function computeSpamListUpdates(spamUsers, rehabilitatedUsers) {
Expand Down Expand Up @@ -121,7 +129,7 @@ module.exports = async ({github, context, core}) => {
const searches = [
{
name: 'spam PRs',
query: `repo:${owner}/${repo} is:pr is:closed -is:merged label:spam`,
query: `repo:${owner}/${repo} is:pr is:closed -is:merged label:"${LABEL_SPAM}"`,
process: async (pr) => {
if (!pr.user?.login) {
console.log(`Skipping PR #${pr.number}: user account unavailable`);
Expand Down Expand Up @@ -208,7 +216,7 @@ module.exports = async ({github, context, core}) => {
const { data: existing } = await github.rest.issues.listForRepo({
owner,
repo,
labels: 'spam-list-update',
labels: LABEL_SPAM_LIST_UPDATE,
state: 'open',
per_page: 1
});
Expand All @@ -221,7 +229,7 @@ module.exports = async ({github, context, core}) => {
repo,
title,
body,
labels: ['spam-list-update', 'automated']
labels: [LABEL_SPAM_LIST_UPDATE, 'automated']
});
console.log('Issue created successfully');
}
Expand Down
Loading