generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve RCP communication by sending out reminders (#3070)
* Improve RCP communication * Only run this on the adobecom repo * Wording * Prettify the file
- Loading branch information
Showing
5 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const { | ||
slackNotification, | ||
getLocalConfigs, | ||
RCPDates, | ||
} = require('./helpers.js'); | ||
|
||
const isWithin24Hours = (targetDate) => | ||
Math.abs(new Date() - targetDate) <= 24 * 60 * 60 * 1000; | ||
|
||
const calculateDateOffset = (date, offset) => { | ||
const newDate = new Date(date); | ||
newDate.setDate(newDate.getDate() - offset); | ||
return newDate; | ||
}; | ||
|
||
// Run from the root of the project for local testing: node --env-file=.env .github/workflows/rcp-notifier.js | ||
const main = async () => { | ||
console.log('Action: RCP Notifier started'); | ||
for (const rcp of RCPDates) { | ||
const start = new Date(rcp.start); | ||
const end = new Date(rcp.end); | ||
const tenDaysBefore = calculateDateOffset(start, 10); | ||
const fourDaysBefore = calculateDateOffset(start, 4); | ||
const stageOffset = Number(process.env.STAGE_RCP_OFFSET_DAYS) || 2; | ||
const slackText = (days) => | ||
`Reminder RCP starts in ${days} days: from ${start.toUTCString()} to ${end.toUTCString()}. Merges to stage will be disabled beginning ${calculateDateOffset(start, stageOffset).toUTCString()}.`; | ||
if (isWithin24Hours(tenDaysBefore)) { | ||
console.log('Is within 24 hours of 10 days before RCP'); | ||
await slackNotification(slackText(10), process.env.MILO_DEV_HOOK); | ||
} | ||
|
||
if (isWithin24Hours(fourDaysBefore)) { | ||
console.log('Is within 24 hours of 4 days before RCP'); | ||
await slackNotification(slackText(4), process.env.MILO_DEV_HOOK); | ||
} | ||
} | ||
|
||
console.log('Action: RCP Notifier completed'); | ||
}; | ||
|
||
if (process.env.LOCAL_RUN) { | ||
const { context } = getLocalConfigs(); | ||
main({ context }); | ||
} | ||
|
||
module.exports = main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: RCP Notifier | ||
|
||
on: | ||
schedule: | ||
- cron: '43 9 * * *' # 9.43am UTC | ||
|
||
env: | ||
STAGE_RCP_OFFSET_DAYS: ${{ secrets.STAGE_RCP_OFFSET_DAYS }} | ||
MILO_DEV_HOOK: ${{ secrets.MILO_DEV_HOOK }} | ||
|
||
jobs: | ||
rcp-notification: | ||
if: github.repository_owner == 'adobecom' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create RCP Notification | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const main = require('./.github/workflows/rcp-notifier.js') | ||
main({ github, context }) |