forked from adobecom/milo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
354 changed files
with
23,350 additions
and
14,605 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const { slackNotification, getLocalConfigs } = require('./helpers.js'); | ||
|
||
const fedsFolders = [ | ||
'libs/blocks/global-navigation', | ||
'libs/blocks/global-footer', | ||
'libs/blocks/modal', | ||
'libs/navigation', | ||
'libs/scripts/delayed', | ||
'libs/utils/utils', | ||
'libs/utils/locales', | ||
'libs/utils/federated', | ||
'libs/martech/attributes', | ||
]; | ||
|
||
const safely = (fn) => { | ||
return (...args) => { | ||
try { | ||
fn(...args); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}; | ||
} | ||
|
||
const main = safely(async ({ github, context }) => { | ||
const number = context.issue?.number || process.env.ISSUE; | ||
const owner = context.repo.owner; | ||
const repo = context.repo.repo; | ||
const { data: files } = await github.rest.pulls.listFiles({ | ||
owner, | ||
repo, | ||
pull_number: number, | ||
}); | ||
|
||
const affectedFedsFiles = files | ||
.map(({ filename }) => filename) | ||
.filter(filename => fedsFolders.some(x => filename.startsWith(x))); | ||
|
||
const message = `> PR <https://github.com/adobecom/milo/pull/${number}|#${number}> affects:\n> \`\`\`${affectedFedsFiles.join('\n')}\`\`\``; | ||
const webhook = process.env.FEDS_WATCH_HOOK; | ||
|
||
if (!affectedFedsFiles.length) { | ||
console.log("No affected Feds Files. Exiting"); | ||
return; | ||
} | ||
slackNotification(message, webhook) | ||
.then((resp) => { | ||
if (resp.ok) console.log('message posted on slack'); | ||
else throw new Error(resp); | ||
}) | ||
.catch(console.error); | ||
}); | ||
|
||
if (process.env.LOCAL_RUN) { | ||
const { github, context } = getLocalConfigs(); | ||
main({ | ||
github, | ||
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,25 @@ | ||
name: Feds File Watch | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, labeled] | ||
|
||
env: | ||
FEDS_WATCH_HOOK: ${{ secrets.FEDS_WATCH_HOOK }} | ||
|
||
jobs: | ||
send_alert: | ||
if: github.repository_owner == 'adobecom' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.base.ref }} | ||
|
||
- name: Send Slack messages if a PR contains feds related files. | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const main = require('./.github/workflows/check-feds-files.js') | ||
main({ github, context }) |
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 }) |
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 |
---|---|---|
|
@@ -10,3 +10,4 @@ logs/* | |
**/mas/*/stats.json | ||
test-html-results/ | ||
test-results/ | ||
test-a11y-results/ |
Oops, something went wrong.