Close Spam Issues #27
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
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: | |
github-token: ${{ secrets.GH_TOKEN }} | |
script: | | |
// ADD SPAM USERS TO THIS LIST | |
const spamUsers = ['Krakensu', 'Botakjelek', 'pemainlama', 'imyourmanposs', 'clav-code', 'sarahagus', 'teisanilan', 'jagat3131', 'sorenmoren6', 'SDGTAL', 'jedaymc', 'eztillieiium', 'danasatria89', 'puput212306']; | |
const issueCreator = context.payload.issue ? context.payload.issue.user.login : null; | |
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)) { | |
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(); |