mirror of
https://github.com/Mail-0/Zero.git
synced 2026-06-29 07:16:19 +00:00
feat: add auto closing of issues / pull requests based on staleness (#1944)
<!-- This is an auto-generated description by cubic. --> ## Summary by cubic Added GitHub workflows to automatically close stale issues and pull requests with unresolved merge conflicts older than 3 days. - **Automation** - Closes open pull requests with merge conflicts after 3 days. - Closes issues immediately when marked as stale. <!-- End of auto-generated description by cubic. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Introduced automated workflows to close old pull requests with unresolved merge conflicts and to close stale issues, helping keep the repository clean and up to date. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
50
.github/workflows/close-conflicted-prs.yml
vendored
Normal file
50
.github/workflows/close-conflicted-prs.yml
vendored
Normal file
@@ -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'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
21
.github/workflows/close-stale-issues.yml
vendored
Normal file
21
.github/workflows/close-stale-issues.yml
vendored
Normal file
@@ -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."
|
||||
Reference in New Issue
Block a user