Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-148054-mnemonics-in-text-block
Browse files Browse the repository at this point in the history
  • Loading branch information
mirafedas committed Jun 4, 2024
2 parents c49524f + fe0adb4 commit eb97805
Show file tree
Hide file tree
Showing 46 changed files with 1,032 additions and 124 deletions.
62 changes: 61 additions & 1 deletion .github/workflows/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,60 @@
const owner = process.env.REPO_OWNER || ''; // example owner: adobecom
const repo = process.env.REPO_NAME || ''; // example repo name: milo
const auth = process.env.GH_TOKEN || ''; // https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
const CURRENT_YEAR = 2024;
const RCPDates = [
{
start: new Date('2024-05-26T00:00:00-07:00'),
end: new Date('2024-06-01T00:00:00-07:00'),
},
{
start: new Date('2024-06-13T11:00:00-07:00'),
end: new Date('2024-06-13T14:00:00-07:00'),
},
{
start: new Date('2024-06-30T00:00:00-07:00'),
end: new Date('2024-07-06T00:00:00-07:00'),
},
{
start: new Date('2024-08-25T00:00:00-07:00'),
end: new Date('2024-08-31T00:00:00-07:00'),
},
{
start: new Date('2024-09-12T11:00:00-07:00'),
end: new Date('2024-09-12T14:00:00-07:00'),
},
{
start: new Date('2024-10-14T00:00:00-07:00'),
end: new Date('2024-11-18T17:00:00-08:00'),
},
{
start: new Date('2024-11-17T00:00:00-08:00'),
end: new Date('2024-11-30T00:00:00-08:00'),
},
{
start: new Date('2024-12-12T11:00:00-08:00'),
end: new Date('2024-12-12T14:00:00-08:00'),
},
{
start: new Date('2024-12-15T00:00:00-08:00'),
end: new Date('2025-01-02T00:00:00-08:00'),
},
];

const isWithinRCP = () => {
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.');
return true;
}

return false;
};

const getLocalConfigs = () => {
if (!owner || !repo || !auth) {
Expand All @@ -12,7 +66,12 @@ Then run: node --env-file=.env .github/workflows/update-ims.js`);

const { Octokit } = require('@octokit/rest');
return {
github: { rest: new Octokit({ auth }) },
github: {
rest: new Octokit({ auth }),
repos: {
createDispatchEvent: () => console.log('local mock createDispatch'),
},
},
context: {
repo: {
owner,
Expand Down Expand Up @@ -83,4 +142,5 @@ module.exports = {
getLocalConfigs,
slackNotification,
pulls: { addLabels, addFiles, getChecks, getReviews },
isWithinRCP,
};
4 changes: 3 additions & 1 deletion .github/workflows/high-impact-alert.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: High Impact Alert

on:
pull_request:
pull_request_target:
types:
- labeled

Expand All @@ -15,6 +15,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.base.ref }}

- name: Send Slack message for high impact PRs
uses: actions/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mark-stale-prs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Close stale pull requests"
name: Close stale pull requests
on:
schedule:
- cron: "0 0 * * *"
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/merge-to-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const {
slackNotification,
getLocalConfigs,
isWithinRCP,
pulls: { addLabels, addFiles, getChecks, getReviews },
} = require('./helpers.js');

// Run from the root of the project for local testing: node --env-file=.env .github/workflows/merge-to-main.js
const PR_TITLE = '[Release] Stage to Main';
const STAGE = 'stage';
const PROD = 'main';

let github, owner, repo;

const getStageToMainPR = () =>
github.rest.pulls
.list({ owner, repo, state: 'open', base: PROD, head: STAGE })
.then(({ data } = {}) => data.find(({ title } = {}) => title === PR_TITLE))
.then((pr) => pr && addLabels({ pr, github, owner, repo }));

const workingHours = () => {
const now = new Date();
const day = now.getUTCDay();
const hour = now.getUTCHours();
const isSunday = day === 0;
const isSaturday = day === 6;
const isFriday = day === 5;
return hour >= 8 && hour <= 20 && !isFriday && !isSaturday && !isSunday;
};

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 (!workingHours()) return console.log('Stopped, outside working hours.');

try {
const stageToMainPR = await getStageToMainPR();
const signOffs = stageToMainPR?.labels.filter((l) => l.includes('SOT'));
console.log(`${signOffs.length} SOT labels on PR ${stageToMainPR.number}`);
if (signOffs.length >= 4) {
console.log('Stage to Main PR has all required labels. Merging...');
await github.rest.pulls.merge({
owner,
repo,
pull_number: stageToMainPR.number,
merge_method: 'merge',
});

await slackNotification(
`:rocket: Production release <${stageToMainPR.html_url}|${stageToMainPR.number}>`
);

await github.rest.repos.createDispatchEvent({
owner,
repo,
event_type: 'merge-to-stage',
});
}

console.log('Process successfully executed.');
} catch (error) {
console.error(error);
}
};

if (process.env.LOCAL_RUN) {
const { github, context } = getLocalConfigs();
main({
github,
context,
});
}

module.exports = main;
37 changes: 37 additions & 0 deletions .github/workflows/merge-to-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Merge to main

on:
pull_request:
types: [labeled]
schedule:
- cron: '0 9 * * *' # Run every day at 9am UTC
workflow_dispatch: # Allow manual trigger

env:
MILO_RELEASE_SLACK_WH: ${{ secrets.MILO_RELEASE_SLACK_WH }}

jobs:
merge-to-main:
runs-on: ubuntu-latest
environment: milo_pr_merge
# Run this when manually triggered or on a schedule
# Otherwise run this only on PRs that are merged from stage to main
if: github.repository_owner == 'adobecom' && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.head.ref == 'stage'))

steps:
- uses: actions/[email protected]
id: milo-pr-merge-token
with:
app-id: ${{ secrets.MILO_PR_MERGE_APP_ID }}
private-key: ${{ secrets.MILO_PR_MERGE_PRIVATE_KEY }}

- name: Checkout repository
uses: actions/[email protected]

- name: Merge to main
uses: actions/[email protected]
with:
github-token: ${{ steps.milo-pr-merge-token.outputs.token }}
script: |
const main = require('./.github/workflows/merge-to-main.js')
main({ github, context })
52 changes: 2 additions & 50 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {
slackNotification,
getLocalConfigs,
isWithinRCP,
pulls: { addLabels, addFiles, getChecks, getReviews },
} = require('./helpers.js');

Expand Down Expand Up @@ -44,45 +45,6 @@ let body = `
- After: https://stage--milo--adobecom.hlx.live/?martech=off
`;

const RCPDates = [
{
start: new Date('2024-05-26T00:00:00-07:00'),
end: new Date('2024-06-01T00:00:00-07:00'),
},
{
start: new Date('2024-06-13T11:00:00-07:00'),
end: new Date('2024-06-13T14:00:00-07:00'),
},
{
start: new Date('2024-06-30T00:00:00-07:00'),
end: new Date('2024-07-06T00:00:00-07:00'),
},
{
start: new Date('2024-08-25T00:00:00-07:00'),
end: new Date('2024-08-31T00:00:00-07:00'),
},
{
start: new Date('2024-09-12T11:00:00-07:00'),
end: new Date('2024-09-12T14:00:00-07:00'),
},
{
start: new Date('2024-10-14T00:00:00-07:00'),
end: new Date('2024-11-18T17:00:00-08:00'),
},
{
start: new Date('2024-11-17T00:00:00-08:00'),
end: new Date('2024-11-30T00:00:00-08:00'),
},
{
start: new Date('2024-12-12T11:00:00-08:00'),
end: new Date('2024-12-12T14:00:00-08:00'),
},
{
start: new Date('2024-12-15T00:00:00-08:00'),
end: new Date('2025-01-02T00:00:00-08:00'),
},
];

const isHighPrio = (labels) => labels.includes(LABELS.highPriority);

const hasFailingChecks = (checks) =>
Expand Down Expand Up @@ -217,18 +179,8 @@ 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.');

const now = new Date();
// We need to revisit this every year
if (now.getFullYear() !== 2024) {
throw new Error('ADD NEW RCPs');
}
for (const { start, end } of RCPDates) {
if (start <= now && now <= end) {
console.log('Current date is within a RCP. Stopping execution.');
return;
}
}
try {
const stageToMainPR = await getStageToMainPR();
console.log('has Stage to Main PR:', !!stageToMainPR);
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/merge-to-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
schedule:
- cron: '0 */4 * * *' # Run every 4 hours
workflow_dispatch: # Allow manual trigger
repository_dispatch:
types: [merge-to-stage]

env:
MILO_RELEASE_SLACK_WH: ${{ secrets.MILO_RELEASE_SLACK_WH }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-reminders.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const main = async ({ github, context }) => {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
base: 'stage',
});

for await (const pr of openPRs) {
Expand Down
5 changes: 3 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
/libs/blocks/mnemonic-list/ @adobecom/tacocat
/libs/blocks/ost/ @adobecom/tacocat
/libs/blocks/pdf-vewer/ @meganthecoder @JasonHowellSlavin @Brandon32
/libs/blocks/quiz/ @colloyd @sabyamon @fullcolorcoder @JackySun9 @elaineskpt @echampio-at-adobe
/libs/blocks/quiz/ @colloyd @sabyamon @fullcolorcoder @JackySun9
/libs/blocks/quiz-entry/ @colloyd @fullcolorcoder @JackySun9
/libs/blocks/quiz-marquee/ @ryanmparrish
/libs/blocks/quiz-results/ @colloyd @sabyamon @fullcolorcoder @JackySun9 @elaineskpt @echampio-at-adobe
/libs/blocks/quiz-results/ @colloyd @sabyamon @fullcolorcoder @JackySun9
/libs/blocks/quote/ @ryanmparrish
/libs/blocks/recommended-articles/ @meganthecoder @JasonHowellSlavin @Brandon32 @rgclayton
/libs/blocks/review/ @nkthakur48 @chrischrischris @auniverseaway
Expand Down
13 changes: 13 additions & 0 deletions libs/blocks/caas-config/caas-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const defaultOptions = {
primary: 'Primary',
'call-to-action': 'Call To Action',
link: 'Link',
dark: 'Dark',
hidden: 'Hide CTAs',
},
container: {
Expand All @@ -90,6 +91,7 @@ const defaultOptions = {
'83Percent': '83% Container',
'32Margin': '32 Margin Container',
carousel: 'Carousel',
categories: 'Product Categories',
},
ctaActions: {
_blank: 'New Tab',
Expand Down Expand Up @@ -183,6 +185,7 @@ const defaultOptions = {
source: {
bacom: 'Bacom',
doccloud: 'DocCloud',
events: 'Events',
experienceleague: 'Experience League',
hawks: 'Hawks',
magento: 'Magento',
Expand All @@ -191,6 +194,7 @@ const defaultOptions = {
northstar: 'Northstar',
workfront: 'Workfront',
'bacom-blog': 'Bacom Blog',
news: 'Newsroom',
},
tagsUrl: 'https://www.adobe.com/chimera-api/tags',
titleHeadingLevel: {
Expand All @@ -210,6 +214,10 @@ const defaultOptions = {
default: 'Default',
modifiedDate: 'Modified Date',
},
cardHoverEffect: {
default: 'Default',
grow: 'Grow',
},
};

const getTagList = (root) => Object.entries(root).reduce((options, [, tag]) => {
Expand Down Expand Up @@ -362,6 +370,11 @@ const UiPanel = () => html`
<${Select} label="Grid Gap (Gutter)" prop="gutter" options=${defaultOptions.gutter} />
<${Select} label="Theme" prop="theme" options=${defaultOptions.theme} />
<${Select} label="Details Text" prop="detailsTextOption" options=${defaultOptions.detailsTextOption} />
<${Select}
label="Card Hover Effect"
prop="cardHoverEffect"
options=${defaultOptions.cardHoverEffect}
/>
<${Select}
label="Collection Button Style"
prop="collectionBtnStyle"
Expand Down
Loading

0 comments on commit eb97805

Please sign in to comment.