From ac469a1bae197fbbaf63c7e57d4d73d3c0a7c634 Mon Sep 17 00:00:00 2001 From: AarDG10 Date: Wed, 22 Apr 2026 11:44:50 +0530 Subject: [PATCH] ci(workflow): add backport reminder Can sometimes forget that a PR was deferred from being backported, adding reminder bot to remind after 2 weeks. --- .github/workflows/backport_reminder.yml | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/backport_reminder.yml diff --git a/.github/workflows/backport_reminder.yml b/.github/workflows/backport_reminder.yml new file mode 100644 index 0000000000..bbc0bbeb13 --- /dev/null +++ b/.github/workflows/backport_reminder.yml @@ -0,0 +1,59 @@ +name: Backport Reminder + +on: + schedule: + - cron: '30 1 * * *' + workflow_dispatch: + +jobs: + remind: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + issues: write + + steps: + - uses: actions/github-script@v8 + with: + script: | + const labelName = 'defer backport'; + const marker = ''; + const waitDays = 14; + const maxDays = 30; + const now = new Date(); + + const query = `is:pr is:merged label:"${labelName}" repo:${context.repo.owner}/${context.repo.repo}`; + const searchResult = await github.rest.search.issuesAndPullRequests({ q: query }); + + for (const pr of searchResult.data.items) { + const { data: fullPr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number + }); + if (!fullPr.merged_at) continue; + const mergedAt = new Date(fullPr.merged_at); + + const diffInDays = (now - mergedAt) / (1000 * 60 * 60 * 24); + + if (diffInDays >= waitDays && diffInDays <= maxDays) { + const comments = await github.paginate(github.rest.issues.listComments, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + per_page: 100 + }); + + const alreadyReminded = comments.some(c => c.body.includes(marker)); + + if (!alreadyReminded) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: `${marker}\n**Backport Reminder**: This PR was merged ${Math.floor(diffInDays)} days ago. Time to backport!` + }); + } + } + } \ No newline at end of file