From 95a6593aaabe22f1c9431e7a887aee8adbceb688 Mon Sep 17 00:00:00 2001 From: Okan Sahin <39759830+mokimo@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:42:42 +0200 Subject: [PATCH] Start the RCP for stage earlier (#2373) Add offset to stage merges --- .github/workflows/helpers.js | 12 +++++++++--- .github/workflows/merge-to-stage.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/helpers.js b/.github/workflows/helpers.js index c086fe88d1..7b36bc38b1 100644 --- a/.github/workflows/helpers.js +++ b/.github/workflows/helpers.js @@ -43,15 +43,21 @@ const RCPDates = [ }, ]; -const isWithinRCP = () => { +const isWithinRCP = (offset = 0) => { const now = new Date(); if (now.getFullYear() !== CURRENT_YEAR) { console.log(`ADD NEW RCPs for ${CURRENT_YEAR + 1}`); return true; } - if (RCPDates.some(({ start, end }) => start <= now && now <= end)) { - console.log('Current date is within a RCP. Stopping execution.'); + if (RCPDates.some(({ start, end }) => { + const adjustedStart = new Date(start); + adjustedStart.setDate(adjustedStart.getDate() - offset); + return start <= now && now <= end + })) { + console.log( + 'Current date is within a RCP (2 days earlier for stage, to keep stage clean & make CSO contributions during an RCP easier). Stopping execution.' + ); return true; } diff --git a/.github/workflows/merge-to-stage.js b/.github/workflows/merge-to-stage.js index 1ce20ca4c4..19ef68f570 100644 --- a/.github/workflows/merge-to-stage.js +++ b/.github/workflows/merge-to-stage.js @@ -179,7 +179,7 @@ const main = async (params) => { github = params.github; owner = params.context.repo.owner; repo = params.context.repo.repo; - if (isWithinRCP()) return console.log('Stopped, within RCP period.'); + if (isWithinRCP(2)) return console.log('Stopped, within RCP period.'); try { const stageToMainPR = await getStageToMainPR();