Skip to content

Commit 0208cea

Browse files
authored
Merge branch 'main' into patch-2
2 parents faf23f9 + a92b82b commit 0208cea

File tree

3,270 files changed

+616960
-263334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,270 files changed

+616960
-263334
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
babelOptions: { configFile: './.babelrc' },
1414
sourceType: 'module',
1515
},
16-
ignorePatterns: ['tmp/*', '!/.*', '/.next/', 'script/bookmarklets/*', 'lib/sigsci.js'],
16+
ignorePatterns: ['tmp/*', '!/.*', '/.next/', 'script/bookmarklets/*'],
1717
rules: {
1818
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
1919
},

.github/actions-scripts/content-changes-table-comment.js

Lines changed: 112 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ if (!APP_URL) {
2020
throw new Error(`APP_URL environment variable not set`)
2121
}
2222

23+
// the max size of the comment (in bytes)
24+
// the action we use to post the comment caps out at about 144kb
25+
// see docs-engineering#1849 for more info
26+
const MAX_COMMENT_SIZE = 125000
27+
2328
const PROD_URL = 'https://docs.github.com'
2429
const octokit = github.getOctokit(GITHUB_TOKEN)
2530

@@ -39,78 +44,117 @@ const pathPrefix = 'content/'
3944
const articleFiles = files.filter(
4045
({ filename }) => filename.startsWith(pathPrefix) && !filename.endsWith('/index.md')
4146
)
42-
for (const file of articleFiles) {
43-
const sourceUrl = file.blob_url
44-
const fileName = file.filename.slice(pathPrefix.length)
45-
const fileUrl = fileName.slice(0, fileName.lastIndexOf('.'))
46-
47-
// get the file contents and decode them
48-
// this script is called from the main branch, so we need the API call to get the contents from the branch, instead
49-
const fileContents = await getContents(
50-
context.repo.owner,
51-
context.payload.repository.name,
52-
context.payload.pull_request.head.sha,
53-
file.filename
54-
)
55-
56-
// parse the frontmatter
57-
const { data } = parse(fileContents)
58-
59-
let contentCell = ''
60-
let previewCell = ''
61-
let prodCell = ''
62-
63-
if (file.status === 'added') contentCell = `New file: `
64-
contentCell += `[\`${fileName}\`](${sourceUrl})`
65-
66-
try {
67-
// the try/catch is needed because getApplicableVersions() returns either [] or throws an error when it can't parse the versions frontmatter
68-
// try/catch can be removed if docs-engineering#1821 is resolved
69-
// i.e. for feature based versioning, like ghae: 'issue-6337'
70-
const fileVersions = getApplicableVersions(data.versions)
71-
72-
for (const plan in allVersionShortnames) {
73-
// plan is the shortName (i.e., fpt)
74-
// allVersionShortNames[plan] is the planName (i.e., free-pro-team)
75-
76-
// walk by the plan names since we generate links differently for most plans
77-
const versions = fileVersions.filter((fileVersion) =>
78-
fileVersion.includes(allVersionShortnames[plan])
79-
)
80-
81-
if (versions.length === 1) {
82-
// for fpt, ghec, and ghae
8347

84-
if (versions.toString() === nonEnterpriseDefaultVersion) {
85-
// omit version from fpt url
86-
87-
previewCell += `[${plan}](${APP_URL}/${fileUrl})<br>`
88-
prodCell += `[${plan}](${PROD_URL}/${fileUrl})<br>`
89-
} else {
90-
// for non-versioned releases (ghae, ghec) use full url
48+
const lines = await Promise.all(
49+
articleFiles.map(async (file) => {
50+
const sourceUrl = file.blob_url
51+
const fileName = file.filename.slice(pathPrefix.length)
52+
const fileUrl = fileName.slice(0, fileName.lastIndexOf('.'))
53+
54+
// get the file contents and decode them
55+
// this script is called from the main branch, so we need the API call to get the contents from the branch, instead
56+
const fileContents = await getContents(
57+
context.repo.owner,
58+
context.payload.repository.name,
59+
// Can't get its content if it no longer exists.
60+
// Meaning, you'd get a 404 on the `getContents()` utility function.
61+
// So, to be able to get necessary meta data about what it *was*,
62+
// if it was removed, fall back to the 'base'.
63+
file.status === 'removed'
64+
? context.payload.pull_request.base.sha
65+
: context.payload.pull_request.head.sha,
66+
file.filename
67+
)
9168

92-
previewCell += `[${plan}](${APP_URL}/${versions}/${fileUrl})<br>`
93-
prodCell += `[${plan}](${PROD_URL}/${versions}/${fileUrl})<br>`
69+
// parse the frontmatter
70+
const { data } = parse(fileContents)
71+
72+
let contentCell = ''
73+
let previewCell = ''
74+
let prodCell = ''
75+
76+
if (file.status === 'added') contentCell = 'New file: '
77+
else if (file.status === 'removed') contentCell = 'Removed: '
78+
contentCell += `[\`${fileName}\`](${sourceUrl})`
79+
80+
try {
81+
// the try/catch is needed because getApplicableVersions() returns either [] or throws an error when it can't parse the versions frontmatter
82+
// try/catch can be removed if docs-engineering#1821 is resolved
83+
// i.e. for feature based versioning, like ghae: 'issue-6337'
84+
const fileVersions = getApplicableVersions(data.versions)
85+
86+
for (const plan in allVersionShortnames) {
87+
// plan is the shortName (i.e., fpt)
88+
// allVersionShortNames[plan] is the planName (i.e., free-pro-team)
89+
90+
// walk by the plan names since we generate links differently for most plans
91+
const versions = fileVersions.filter((fileVersion) =>
92+
fileVersion.includes(allVersionShortnames[plan])
93+
)
94+
95+
if (versions.length === 1) {
96+
// for fpt, ghec, and ghae
97+
98+
if (versions.toString() === nonEnterpriseDefaultVersion) {
99+
// omit version from fpt url
100+
101+
previewCell += `[${plan}](${APP_URL}/${fileUrl})<br>`
102+
prodCell += `[${plan}](${PROD_URL}/${fileUrl})<br>`
103+
} else {
104+
// for non-versioned releases (ghae, ghec) use full url
105+
106+
previewCell += `[${plan}](${APP_URL}/${versions}/${fileUrl})<br>`
107+
prodCell += `[${plan}](${PROD_URL}/${versions}/${fileUrl})<br>`
108+
}
109+
} else if (versions.length) {
110+
// for ghes releases, link each version
111+
112+
previewCell += `${plan}@ `
113+
prodCell += `${plan}@ `
114+
115+
versions.forEach((version) => {
116+
previewCell += `[${version.split('@')[1]}](${APP_URL}/${version}/${fileUrl}) `
117+
prodCell += `[${version.split('@')[1]}](${PROD_URL}/${version}/${fileUrl}) `
118+
})
119+
previewCell += '<br>'
120+
prodCell += '<br>'
94121
}
95-
} else if (versions.length) {
96-
// for ghes releases, link each version
97-
98-
previewCell += `${plan}@ `
99-
prodCell += `${plan}@ `
100-
101-
versions.forEach((version) => {
102-
previewCell += `[${version.split('@')[1]}](${APP_URL}/${version}/${fileUrl}) `
103-
prodCell += `[${version.split('@')[1]}](${PROD_URL}/${version}/${fileUrl}) `
104-
})
105-
previewCell += '<br>'
106-
prodCell += '<br>'
107122
}
123+
} catch (e) {
124+
console.error(
125+
`Version information for ${file.filename} couldn't be determined from its frontmatter.`
126+
)
108127
}
109-
} catch (e) {
110-
console.error(
111-
`Version information for ${file.filename} couldn't be determined from its frontmatter.`
112-
)
128+
let note = ''
129+
if (file.status === 'removed') {
130+
note = 'removed'
131+
// If the file was removed, the `previewCell` no longer makes sense
132+
// since it was based on looking at the base sha.
133+
previewCell = 'n/a'
134+
}
135+
136+
return `| ${contentCell} | ${previewCell} | ${prodCell} | ${note} |`
137+
})
138+
)
139+
140+
// this section limits the size of the comment
141+
const cappedLines = []
142+
let underMax = true
143+
144+
lines.reduce((previous, current, index, array) => {
145+
if (underMax) {
146+
if (previous + current.length > MAX_COMMENT_SIZE) {
147+
underMax = false
148+
cappedLines.push('**Note** There are more changes in this PR than we can show.')
149+
return previous
150+
}
151+
152+
cappedLines.push(array[index])
153+
return previous + current.length
113154
}
114-
markdownTable += `| ${contentCell} | ${previewCell} | ${prodCell} | |\n`
115-
}
155+
return previous
156+
}, markdownTable.length)
157+
158+
markdownTable += cappedLines.join('\n')
159+
116160
setOutput('changesTable', markdownTable)

.github/workflows/autoupdate-branch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ jobs:
4343
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
4444

4545
- name: Setup Node
46-
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561
46+
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
4747
with:
48-
node-version: 16.15.x
48+
node-version: '16.15.0'
4949
cache: npm
5050

5151
- name: Install dependencies

.github/workflows/azure-preview-env-deploy.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188
# `main-docker-cache.yml` handles updating the remote cache so we don't pollute it with PR specific code
189189
cache-to: ''
190190
build-args: |
191-
BUILD_SHA=${{ github.sha }}
191+
BUILD_SHA=${{ env.COMMIT_REF }}
192192
193193
# Succeed despite any non-zero exit code (e.g. if there is no deployment to cancel)
194194
- name: 'Cancel any existing deployments for this PR'
@@ -198,7 +198,16 @@ jobs:
198198
# Deploy ARM template is idempotent
199199
# Note: once the resources exist the image tag must change for a new deployment to occur (the image tag includes workflow run number, run attempt, as well as sha)
200200
- name: Run ARM deploy
201-
id: deploy
201+
# This 'if' will be truth, if this workflow is...
202+
# - run as a workflow_dispatch
203+
# - run because of a push to main (or gh-readonly-queue/main)
204+
# - run as a regular pull request
205+
# But if it's a pull request, *and* for whatever reason, the pull
206+
# request has "Auto-merge" enabled, don't bother.
207+
# The idea is that if auto-merge has been abled, by humans or by
208+
# bots, they have no intention of viewing the deployed preview anyway.
209+
# This saves time because the PR can merge sooner.
210+
if: ${{ !github.event.pull_request.auto_merge }}
202211
uses: azure/arm-deploy@841b12551939c88af8f6df767c24c38a5620fd0d
203212
with:
204213
resourceGroupName: ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }}

.github/workflows/azure-prod-build-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ jobs:
6060
run: git lfs checkout
6161

6262
- name: Setup node
63-
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561
63+
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
6464
with:
65-
node-version: 16.15.x
65+
node-version: '16.15.0'
6666
cache: npm
6767

6868
- name: Clone docs-early-access

0 commit comments

Comments
 (0)