Skip to content

Commit

Permalink
chore: create cron to clean up spam issues (#15745)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley authored Nov 11, 2024
1 parent da597c6 commit 7d28fe4
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/close-spam-issues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Close Spam Issues

on:
schedule:
- cron: '*/20 * * * *' # Runs every 20 minutes
workflow_dispatch:

jobs:
close_spam_issues:
runs-on: ubuntu-latest
steps:
- name: Check and Close Spam Issues
uses: actions/github-script@v7
with:
script: |
// ADD SPAM USERS TO THIS LIST
const spamUsers = ['Krakensu'];
const issueCreator = context.payload.issue.user.login;
async function closeSpamIssues() {
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
for (const issue of issues) {
const issueCreator = issue.user.login;
if (spamUsers.includes(issueCreator)) {
console.log('issue creator:', issueCreator);
// TEST THIS LOGIC WORKS FIRST
// await github.rest.issues.update({
// owner: context.repo.owner,
// repo: context.repo.repo,
// issue_number: issue.number,
// state: 'closed'
// });
// await github.rest.issues.addLabels({
// owner: context.repo.owner,
// repo: context.repo.repo,
// issue_number: issue.number,
// labels: ['resolution: invalid', 'platform: all']
// });
console.log(`Closed issue #${issue.number} created by spam user: ${issueCreator} and added labels.`);
}
}
}
closeSpamIssues();

0 comments on commit 7d28fe4

Please sign in to comment.