From e695f42e852046c1125f17d4af4787c9cc906a4a Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Thu, 2 Nov 2023 15:42:26 -0300 Subject: [PATCH 1/2] Add stalebot schedules to allow processing of all issues --- .github/workflows/scripts/stalebot.js | 25 +++++++++++++++++++ .github/workflows/stalebot.yml | 21 +++++++++++++--- .../changelog/add-stalebot-schedules | 4 +++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/scripts/stalebot.js create mode 100644 plugins/woocommerce/changelog/add-stalebot-schedules diff --git a/.github/workflows/scripts/stalebot.js b/.github/workflows/scripts/stalebot.js new file mode 100644 index 00000000000..af3c5e26c37 --- /dev/null +++ b/.github/workflows/scripts/stalebot.js @@ -0,0 +1,25 @@ +/** + * Set the stalebot start date given a cron schedule. + */ + +// You need to install this dependency as part of your workflow. +const core = require( '@actions/core' ); + +const ScheduleStartDate = () => { + let scheduleStartDate; + + switch ( process.env.CRON_SCHEDULE ) { + case '21 1 * * *': + scheduleStartDate = '2022-01-01'; + case '31 2 * * *': + scheduleStartDate = '2023-01-01'; + case '41 3 * * *': + scheduleStartDate = '2023-08-01'; + default: + scheduleStartDate = '2018-01-01'; + } + + core.setOutput( 'stale-start-date', scheduleStartDate ); +}; + +ScheduleStartDate(); diff --git a/.github/workflows/stalebot.yml b/.github/workflows/stalebot.yml index c3e9f03bee9..719213623f1 100644 --- a/.github/workflows/stalebot.yml +++ b/.github/workflows/stalebot.yml @@ -1,7 +1,10 @@ -name: 'Close stale needs-feedback issues' +name: 'Process stale needs-feedback issues' on: schedule: - - cron: '21 0 * * *' + - cron: '11 0 * * *' + - cron: '21 1 * * *' + - cron: '31 2 * * *' + - cron: '41 3 * * *' permissions: {} @@ -13,10 +16,20 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/stale@v8 + - name: Install Actions Core + run: npm --prefix .github/workflows/scripts install @actions/core + + - name: Get start date + id: startdate + run: node .github/workflows/scripts/stalebot.js + env: + CRON_SCHEDULE: ${{ github.event.schedule }} + - name: Scan issues + uses: actions/stale@v8 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - operations-per-run: 40 + operations-per-run: 8 + start-date: steps.startdate.outputs.stale-start-date stale-issue-message: "As a part of this repository's maintenance, this issue is being marked as stale due to inactivity. Please feel free to comment on it in case we missed something.\n\n###### After 7 days with no activity this issue will be automatically be closed." close-issue-message: 'This issue was closed because it has been 14 days with no activity.' days-before-issue-stale: 7 diff --git a/plugins/woocommerce/changelog/add-stalebot-schedules b/plugins/woocommerce/changelog/add-stalebot-schedules new file mode 100644 index 00000000000..49268dd5210 --- /dev/null +++ b/plugins/woocommerce/changelog/add-stalebot-schedules @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Add stalebot schedules to allow processing of all issues From c738977c21e938fa24ee5a62cfdd7893f2c25e5d Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Thu, 2 Nov 2023 15:57:13 -0300 Subject: [PATCH 2/2] include the switch breaks --- .github/workflows/scripts/stalebot.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/scripts/stalebot.js b/.github/workflows/scripts/stalebot.js index af3c5e26c37..83b28292d49 100644 --- a/.github/workflows/scripts/stalebot.js +++ b/.github/workflows/scripts/stalebot.js @@ -11,12 +11,16 @@ const ScheduleStartDate = () => { switch ( process.env.CRON_SCHEDULE ) { case '21 1 * * *': scheduleStartDate = '2022-01-01'; + break; case '31 2 * * *': scheduleStartDate = '2023-01-01'; + break; case '41 3 * * *': scheduleStartDate = '2023-08-01'; + break; default: scheduleStartDate = '2018-01-01'; + break; } core.setOutput( 'stale-start-date', scheduleStartDate );