diff --git a/.github/workflows/close-conflicted-prs.yml b/.github/workflows/close-conflicted-prs.yml new file mode 100644 index 000000000..4cb12112f --- /dev/null +++ b/.github/workflows/close-conflicted-prs.yml @@ -0,0 +1,50 @@ +name: Close Old Conflicted PRs + +on: + schedule: + - cron: "0 * * * *" + +jobs: + close_conflicted_prs: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Close PRs with merge conflicts older than 3 days + uses: actions/github-script@v7 + with: + script: | + const prs = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + + const now = new Date(); + for (const pr of prs.data) { + const details = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number + }); + + if (details.data.mergeable === false || details.data.mergeable === null) { + const createdAt = new Date(pr.created_at); + const diffDays = (now - createdAt) / (1000 * 60 * 60 * 24); + if (diffDays > 3) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: "This PR has merge conflicts and has been open for more than 3 days. It will be automatically closed. Please resolve the conflicts and reopen the PR if you'd like to continue working on it." + }); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + state: 'closed' + }); + } + } + } diff --git a/.github/workflows/close-stale-issues.yml b/.github/workflows/close-stale-issues.yml new file mode 100644 index 000000000..1457e1c9d --- /dev/null +++ b/.github/workflows/close-stale-issues.yml @@ -0,0 +1,21 @@ +name: Close Stale Issues + +on: + schedule: + - cron: "0 * * * *" + +jobs: + stale: + runs-on: ubuntu-latest + permissions: + issues: write + contents: read + steps: + - uses: actions/stale@v9 + with: + days-before-stale: 3 + days-before-close: 0 + only-issues: true + stale-issue-label: "stale" + stale-issue-message: "This issue is stale (3+ days) and will be closed." + close-issue-message: "Closing stale issue."