Skip to content

Commit

Permalink
Merge branch 'main' into rparrish/img-links-aria-label
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmparrish committed May 31, 2024
2 parents 36d7489 + b8b1871 commit 31ef7e8
Show file tree
Hide file tree
Showing 446 changed files with 29,026 additions and 10,604 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/auto-merge-main-to-stage.yml

This file was deleted.

7 changes: 6 additions & 1 deletion .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- stage

jobs:
dispatch-dc:
Expand All @@ -16,6 +17,7 @@ jobs:
- uses: dorny/paths-filter@v2
id: changes
with:
base: ${{ github.ref }}
filters: |
src:
- 'libs/**'
Expand All @@ -29,5 +31,8 @@ jobs:
owner: 'adobecom',
repo: 'dc',
workflow_id: 'test-milo.yml',
ref: 'main',
ref: 'stage',
inputs: {
miloBranch: '${{ github.ref_name }}'
},
})
26 changes: 0 additions & 26 deletions .github/workflows/email-release.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/enforce-labels.yml

This file was deleted.

28 changes: 25 additions & 3 deletions .github/workflows/fg-sync-repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ name: Floodgate Repo Sync

on:
workflow_dispatch:
inputs:
syncBranch:
description: 'Branch to sync'
required: true
default: 'stage'
type: choice
options:
- 'stage'
- 'main'

jobs:
build:
Expand All @@ -20,27 +29,40 @@ jobs:
uses: actions/checkout@v2
with:
persist-credentials: false
ref: ${{ inputs.syncBranch }}

- name: Clone Floodgate Repository
- name: Clone Floodgate Repository and Checkout Selected Branch
run: |
git clone https://github.com/adobecom/milo-pink.git ../milo-pink
cd ../milo-pink
git checkout $FG_SYNC_BRANCH
echo "milo-pink branch"
git branch
cd ../milo
echo "milo branch"
git branch
env:
FG_SYNC_BRANCH: ${{ inputs.syncBranch }}

- name: Overwrite floodgate repo files with latest from source repo
run: |
rsync -av --exclude='fstab.yaml' --exclude='.github' --exclude='.git' --exclude='.idea' ./ ../milo-pink/
rsync -av --exclude='fstab.yaml' --exclude='.github' --exclude='.kodiak' --exclude='.git' --exclude='.idea' --exclude='.husky' --exclude='.vscode' --exclude='tools/sidekick/config.json' ./ ../milo-pink/
- name: Commit and Push Changes to Floodgate Repository
run: |
cd ../milo-pink
echo "milo-pink branch"
git branch
git config user.email "$FG_SYNC_BOT_EMAIL"
git config user.name "$FG_SYNC_BOT_NAME"
git status
git remote set-url origin https://oauth2:[email protected]/adobecom/milo-pink.git
git remote -v
git add .
git commit -m "Syncing milo to milo-pink"
git push origin main --force
git push origin $FG_SYNC_BRANCH --force
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
FG_SYNC_BOT_EMAIL: ${{ secrets.FG_SYNC_BOT_EMAIL }}
FG_SYNC_BOT_NAME: ${{ secrets.FG_SYNC_BOT_NAME }}
FG_SYNC_BRANCH: ${{ inputs.syncBranch }}
86 changes: 86 additions & 0 deletions .github/workflows/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Those env variables are set by an github action automatically
// For local testing, you should test on your fork.
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 getLocalConfigs = () => {
if (!owner || !repo || !auth) {
throw new Error(`Create a .env file on the root of the project with credentials.
Then run: node --env-file=.env .github/workflows/update-ims.js`);
}

const { Octokit } = require('@octokit/rest');
return {
github: { rest: new Octokit({ auth }) },
context: {
repo: {
owner,
repo,
},
},
};
};

const slackNotification = (text, webhook) => {
console.log(text);
return fetch(webhook || process.env.MILO_RELEASE_SLACK_WH, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ text }),
});
};

const addLabels = ({ pr, github, owner, repo }) =>
github.rest.issues
.listLabelsOnIssue({ owner, repo, issue_number: pr.number })
.then(({ data }) => {
pr.labels = data.map(({ name }) => name);
return pr;
});

const addFiles = ({ pr, github, owner, repo }) =>
github.rest.pulls
.listFiles({ owner, repo, pull_number: pr.number })
.then(({ data }) => {
pr.files = data.map(({ filename }) => filename);
return pr;
});

const getChecks = ({ pr, github, owner, repo }) =>
github.rest.checks
.listForRef({ owner, repo, ref: pr.head.sha })
.then(({ data }) => {
const checksByName = data.check_runs.reduce((map, check) => {
if (
!map.has(check.name) ||
new Date(map.get(check.name).completed_at) <
new Date(check.completed_at)
) {
map.set(check.name, check);
}
return map;
}, new Map());
pr.checks = Array.from(checksByName.values());
return pr;
});

const getReviews = ({ pr, github, owner, repo }) =>
github.rest.pulls
.listReviews({
owner,
repo,
pull_number: pr.number,
})
.then(({ data }) => {
pr.reviews = data;
return pr;
});

module.exports = {
getLocalConfigs,
slackNotification,
pulls: { addLabels, addFiles, getChecks, getReviews },
};
73 changes: 73 additions & 0 deletions .github/workflows/label-zero-impact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const { getLocalConfigs } = require('./helpers.js');
const zeroImpactDirs = [
'.github',
'.kodiak',
'.vscode',
'.test',
'libs/mep',
'.eslintrc.js',
'CODEOWNERS',
'web-test-runner.config.mjs',
'LICENSE',
'codecov.yaml',
'.gitignore',
];
const zeroImpactLabel = 'zero-impact';

// Run from the root of the project for local testing: node --env-file=.env .github/workflows/label-zero-impact.js
const main = async ({ github, context }) => {
const number = context.issue?.number || process.env.ISSUE;
const owner = context.repo.owner;
const repo = context.repo.repo;

try {
const { data: files } = await github.rest.pulls.listFiles({
owner,
repo,
pull_number: number,
});

const isZeroImpactPR = files.every(({ filename }) =>
zeroImpactDirs.some((dir) => filename.startsWith(dir))
);
console.log(`PR ${number} is zero impact: ${isZeroImpactPR}.`);
if (isZeroImpactPR) {
console.log('Adding zero-impact label to PR.');
await github.rest.issues.addLabels({
owner,
repo,
issue_number: number,
labels: [zeroImpactLabel],
});
} else {
console.log('Removing zero-impact label from PR.');
await github.rest.issues.removeLabel({
owner,
repo,
issue_number: number,
name: zeroImpactLabel,
});
console.log('Posting a comment on the PR.');
await github.rest.issues.createComment({
owner,
repo,
issue_number: number,
body: 'This PR does not qualify for the zero-impact label as it touches code outside of the allowed areas. The label is auto applied, do not manually apply the label.',
});
}

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;
20 changes: 20 additions & 0 deletions .github/workflows/label-zero-impact.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Add or remove zero impact label

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]

jobs:
label:
runs-on: ubuntu-latest

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

- name: Add the zero impact label
uses: actions/[email protected]
with:
script: |
const main = require('./.github/workflows/label-zero-impact.js')
main({ github, context })
19 changes: 19 additions & 0 deletions .github/workflows/mark-stale-prs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Close stale pull requests"
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR has not been updated recently and will be closed in 7 days if no action is taken. Please ensure all checks are passing, https://github.com/orgs/adobecom/discussions/997 provides instructions. If the PR is ready to be merged, please mark it with the "Ready for Stage" label.'
close-pr-message: 'Closing this PR due to inactivity.'
days-before-stale: 7
days-before-close: 7
exempt-pr-labels: 'Ready for Stage'
operations-per-run: 100
Loading

0 comments on commit 31ef7e8

Please sign in to comment.