Auto Close Old Issues #1
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: Auto Close Old Issues | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
close_old_issues: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check and Close Old Issues | |
uses: actions/github-script@v5 | |
with: | |
github-token: ${{ secrets.BOT_TOKEN }} | |
script: | | |
const octokit = new github.getOctokit("${{secrets.BOT_TOKEN}}"); | |
const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000); | |
const issues = await octokit.rest.issues.listForRepo({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
since: thirtyDaysAgo.toISOString(), | |
}); | |
for (const issue of issues.data) { | |
await octokit.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue.number, | |
state: 'closed', | |
}); | |
} | |