-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create cron to clean up spam issues (#15745)
- Loading branch information
1 parent
da597c6
commit 7d28fe4
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |