diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yml similarity index 100% rename from .github/workflows/build.yaml rename to .github/workflows/build.yml diff --git a/.github/workflows/close-issue.yml b/.github/workflows/close-issue.yml new file mode 100644 index 0000000..a0a5d83 --- /dev/null +++ b/.github/workflows/close-issue.yml @@ -0,0 +1,38 @@ +name: Close Inactive Issues + +on: + schedule: + # run every day at midnight + - cron: "0 0 * * *" + +jobs: + close_inactive_issues: + runs-on: ubuntu-latest + steps: + - name: Check inactive issues and close them + uses: actions/github-script@v6 + with: + script: | + const { data: issues } = await github.rest.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + }); + + const now = new Date().getTime(); + const inactivePeriod = 7 * 24 * 60 * 60 * 1000; // 7 days + + for (const issue of issues) { + const lastUpdated = new Date(issue.updated_at).getTime(); + + // if the issue hasn't been updated in the past week, close it + if (now - lastUpdated > inactivePeriod) { + console.log(`Closing inactive issue: ${issue.number}`); + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + state: 'closed', + }); + } + } diff --git a/.github/workflows/update-pages.yaml b/.github/workflows/update-pages.yml similarity index 100% rename from .github/workflows/update-pages.yaml rename to .github/workflows/update-pages.yml