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:
amrit
2025-08-07 14:19:31 +05:30
committed by GitHub
parent b0f860003f
commit 76b7330e0c
2 changed files with 27 additions and 8 deletions

View File

@@ -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({

View File

@@ -2,7 +2,7 @@ name: Close Stale Issues
on:
schedule:
- cron: "0 * * * *"
- cron: "0 0 * * *"
jobs:
stale: