generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rparrish/img-links-aria-label
- Loading branch information
Showing
446 changed files
with
29,026 additions
and
10,604 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -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: | ||
|
@@ -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 }} |
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,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 }, | ||
}; |
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,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; |
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,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 }) |
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,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 |
Oops, something went wrong.