mirror of
https://github.com/Mail-0/Zero.git
synced 2026-06-28 06:46:15 +00:00
fix: update cron schedule and improve conflict detection in PR closures (#1945)
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This commit is contained in:
33
.github/workflows/close-conflicted-prs.yml
vendored
33
.github/workflows/close-conflicted-prs.yml
vendored
@@ -2,7 +2,7 @@ name: Close Old Conflicted PRs
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 * * * *"
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
close_conflicted_prs:
|
||||
@@ -10,7 +10,7 @@ jobs:
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Close PRs with merge conflicts older than 3 days
|
||||
- name: Close PRs with conflicts older than 3 days
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
@@ -28,15 +28,34 @@ jobs:
|
||||
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) {
|
||||
if (details.data.mergeable === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (details.data.mergeable === false) {
|
||||
const timeline = await github.rest.issues.listEventsForTimeline({ owner: context.repo.owner, repo: context.repo.repo, issue_number: pr.number, per_page: 100 });
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: pr.number
|
||||
});
|
||||
|
||||
let conflictStartTime = new Date(pr.updated_at);
|
||||
|
||||
for (const event of timeline.data) {
|
||||
if (event.event === 'cross-referenced' && event.commit_id) {
|
||||
conflictStartTime = new Date(event.created_at);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const conflictAgeDays = (now - conflictStartTime) / (1000 * 60 * 60 * 24);
|
||||
|
||||
if (conflictAgeDays >= 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."
|
||||
body: "This PR has had merge conflicts 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({
|
||||
|
||||
2
.github/workflows/close-stale-issues.yml
vendored
2
.github/workflows/close-stale-issues.yml
vendored
@@ -2,7 +2,7 @@ name: Close Stale Issues
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 * * * *"
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
|
||||
Reference in New Issue
Block a user