generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 175
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/share-update
- Loading branch information
Showing
252 changed files
with
9,242 additions
and
9,028 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
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,25 @@ | ||
// 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: process.env.GH_TOKEN }) }, | ||
context: { | ||
repo: { | ||
owner, | ||
repo, | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
module.exports = getLocalConfigs; |
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 |
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,133 @@ | ||
// Run from the root of the project for local testing: node --env-file=.env .github/workflows/pr-reminders.js | ||
|
||
const main = async ({ github, context }) => { | ||
const comment = async ({ pr, message, comments }) => { | ||
if (comments.some((c) => c.body.includes(message))) { | ||
console.log( | ||
`PR #${pr.number} Comment exists. Commenting skipped... ${message}` | ||
); | ||
return; | ||
} | ||
process.env.LOCAL_RUN | ||
? console.log( | ||
`PR #${pr.number} Local execution commenting SKIPPED message: ${message}` | ||
) | ||
: await github.rest.issues | ||
.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: pr.number, | ||
body: message, | ||
}) | ||
.then(() => console.log(`PR #${pr.number} Commented: ${message}`)) | ||
.catch(console.error); | ||
}; | ||
|
||
const getLatestChecks = async ({ pr }) => { | ||
const { data: checks } = await github.rest.checks | ||
.listForRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: pr.head.sha, | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
return { data: { check_runs: [] } }; | ||
}); | ||
const checksByName = checks.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()); | ||
return Array.from(checksByName.values()); | ||
}; | ||
|
||
try { | ||
const { data: openPRs } = await github.rest.pulls.list({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
state: 'open', | ||
}); | ||
|
||
for await (const pr of openPRs) { | ||
const { data: labels } = await github.rest.issues.listLabelsOnIssue({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: pr.number, | ||
}); | ||
|
||
if (labels.some(({ name } = {}) => name === 'Ready for Stage' || name === 'Stale')) { | ||
console.log( | ||
`PR #${pr.number} has the 'Ready for Stage' or 'Stale' label. Skipping...` | ||
); | ||
continue; | ||
} | ||
|
||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: pr.number, | ||
}); | ||
|
||
const latestChecks = await getLatestChecks({ github, context, pr }); | ||
if (latestChecks.some((check) => check.conclusion === 'failure')) { | ||
comment({ | ||
pr, | ||
comments, | ||
message: | ||
'This pull request is not passing all required checks. Please see [this discussion](https://github.com/orgs/adobecom/discussions/997) for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.', | ||
}); | ||
continue; | ||
} | ||
|
||
const { data: reviews } = await github.rest.pulls.listReviews({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: pr.number, | ||
}); | ||
|
||
if (reviews.some((review) => review.state === 'CHANGES_REQUESTED')) { | ||
console.log(`PR #${pr.number} has changes requested. Skipping...`); | ||
continue; | ||
} | ||
|
||
if (reviews.filter((review) => review.state === 'APPROVED').length < 2) { | ||
console.log(`PR #${pr.number} has less than 2 approvals. Skipping...`); | ||
continue; | ||
} | ||
|
||
if(labels.some(({ name } = {}) => name === 'needs-verification')) { | ||
comment({ | ||
pr, | ||
comments, | ||
message: 'This PR is currently in the `needs-verification` state. Please assign a QA engineer to verify the changes.' | ||
}) | ||
continue; | ||
} | ||
|
||
comment({ | ||
pr, | ||
comments, | ||
message: | ||
'Reminder to set the `Ready for Stage` label - to queue this to get merged to stage & production.', | ||
}); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
if (process.env.LOCAL_RUN) { | ||
const { github, context } = require('./localWorkflowConfigs.js')(); | ||
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,23 @@ | ||
name: PR Reminders | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Remind PR initiators | ||
uses: actions/github-script@v7.0.1 | ||
with: | ||
script: | | ||
const main = require('./.github/workflows/pr-reminders.js') | ||
main({ github, context }) | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,30 @@ | ||
name: Update dependencies | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Update file and create PR if needed | ||
uses: actions/github-script@v7.0.1 | ||
with: | ||
script: | | ||
const updateDependency = require('./.github/workflows/update-script.js') | ||
updateDependency({ | ||
github, | ||
context, | ||
title: '[AUTOMATED-PR] Update imslib.min.js dependency', | ||
path: 'https://auth.services.adobe.com/imslib/imslib.min.js', | ||
branch: 'update-imslib', | ||
scriptPath: './libs/deps/imslib.min.js' | ||
}) | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Oops, something went wrong.