Skip to content

Commit 6ed502c

Browse files
authored
Merge branch 'main' into uninstalling-webhooks
2 parents e6f56f2 + f95deac commit 6ed502c

File tree

888 files changed

+159140
-6764
lines changed

Some content is hidden

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

888 files changed

+159140
-6764
lines changed

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

Lines changed: 88 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -39,78 +39,97 @@ const pathPrefix = 'content/'
3939
const articleFiles = files.filter(
4040
({ filename }) => filename.startsWith(pathPrefix) && !filename.endsWith('/index.md')
4141
)
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
83-
84-
if (versions.toString() === nonEnterpriseDefaultVersion) {
85-
// omit version from fpt url
8642

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
43+
const lines = await Promise.all(
44+
articleFiles.map(async (file) => {
45+
const sourceUrl = file.blob_url
46+
const fileName = file.filename.slice(pathPrefix.length)
47+
const fileUrl = fileName.slice(0, fileName.lastIndexOf('.'))
48+
49+
// get the file contents and decode them
50+
// this script is called from the main branch, so we need the API call to get the contents from the branch, instead
51+
const fileContents = await getContents(
52+
context.repo.owner,
53+
context.payload.repository.name,
54+
// Can't get its content if it no longer exists.
55+
// Meaning, you'd get a 404 on the `getContents()` utility function.
56+
// So, to be able to get necessary meta data about what it *was*,
57+
// if it was removed, fall back to the 'base'.
58+
file.status === 'removed'
59+
? context.payload.pull_request.base.sha
60+
: context.payload.pull_request.head.sha,
61+
file.filename
62+
)
9163

92-
previewCell += `[${plan}](${APP_URL}/${versions}/${fileUrl})<br>`
93-
prodCell += `[${plan}](${PROD_URL}/${versions}/${fileUrl})<br>`
64+
// parse the frontmatter
65+
const { data } = parse(fileContents)
66+
67+
let contentCell = ''
68+
let previewCell = ''
69+
let prodCell = ''
70+
71+
if (file.status === 'added') contentCell = 'New file: '
72+
else if (file.status === 'removed') contentCell = 'Removed: '
73+
contentCell += `[\`${fileName}\`](${sourceUrl})`
74+
75+
try {
76+
// the try/catch is needed because getApplicableVersions() returns either [] or throws an error when it can't parse the versions frontmatter
77+
// try/catch can be removed if docs-engineering#1821 is resolved
78+
// i.e. for feature based versioning, like ghae: 'issue-6337'
79+
const fileVersions = getApplicableVersions(data.versions)
80+
81+
for (const plan in allVersionShortnames) {
82+
// plan is the shortName (i.e., fpt)
83+
// allVersionShortNames[plan] is the planName (i.e., free-pro-team)
84+
85+
// walk by the plan names since we generate links differently for most plans
86+
const versions = fileVersions.filter((fileVersion) =>
87+
fileVersion.includes(allVersionShortnames[plan])
88+
)
89+
90+
if (versions.length === 1) {
91+
// for fpt, ghec, and ghae
92+
93+
if (versions.toString() === nonEnterpriseDefaultVersion) {
94+
// omit version from fpt url
95+
96+
previewCell += `[${plan}](${APP_URL}/${fileUrl})<br>`
97+
prodCell += `[${plan}](${PROD_URL}/${fileUrl})<br>`
98+
} else {
99+
// for non-versioned releases (ghae, ghec) use full url
100+
101+
previewCell += `[${plan}](${APP_URL}/${versions}/${fileUrl})<br>`
102+
prodCell += `[${plan}](${PROD_URL}/${versions}/${fileUrl})<br>`
103+
}
104+
} else if (versions.length) {
105+
// for ghes releases, link each version
106+
107+
previewCell += `${plan}@ `
108+
prodCell += `${plan}@ `
109+
110+
versions.forEach((version) => {
111+
previewCell += `[${version.split('@')[1]}](${APP_URL}/${version}/${fileUrl}) `
112+
prodCell += `[${version.split('@')[1]}](${PROD_URL}/${version}/${fileUrl}) `
113+
})
114+
previewCell += '<br>'
115+
prodCell += '<br>'
94116
}
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>'
107117
}
118+
} catch (e) {
119+
console.error(
120+
`Version information for ${file.filename} couldn't be determined from its frontmatter.`
121+
)
108122
}
109-
} catch (e) {
110-
console.error(
111-
`Version information for ${file.filename} couldn't be determined from its frontmatter.`
112-
)
113-
}
114-
markdownTable += `| ${contentCell} | ${previewCell} | ${prodCell} | |\n`
115-
}
123+
let note = ''
124+
if (file.status === 'removed') {
125+
note = 'removed'
126+
// If the file was removed, the `previewCell` no longer makes sense
127+
// since it was based on looking at the base sha.
128+
previewCell = 'n/a'
129+
}
130+
131+
return `| ${contentCell} | ${previewCell} | ${prodCell} | ${note} |`
132+
})
133+
)
134+
markdownTable += lines.join('\n')
116135
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

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

Lines changed: 134 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,144 @@ permissions:
2020
contents: read
2121
deployments: write
2222

23+
# This allows a subsequently queued workflow run to take priority over
24+
# previously queued runs but NOT interrupt currently executing runs
25+
concurrency:
26+
group: 'staging-env @ ${{ github.head_ref || github.run_id }} for ${{ github.event.number || github.event.inputs.PR_NUMBER }}'
27+
cancel-in-progress: true
28+
2329
jobs:
2430
azure-staging-build-and-deploy:
2531
if: ${{ github.repository == 'github/docs-internal' }}
2632
runs-on: ubuntu-latest
33+
timeout-minutes: 20
34+
environment:
35+
# TODO: Update name and url to point to a specific slot for the branch/PR
36+
name: staging-env
37+
url: ${{ env.APP_URL }}
38+
env:
39+
PR_NUMBER: ${{ github.event.number || github.event.inputs.PR_NUMBER || github.run_id }}
40+
COMMIT_REF: ${{ github.event.pull_request.head.sha || github.event.inputs.COMMIT_REF }}
41+
IMAGE_REPO: ${{ github.repository }}/pr-${{ github.event.number || github.event.inputs.PR_NUMBER || github.run_id }}
42+
RESOURCE_GROUP_NAME: docs-staging
43+
APP_SERVICE_NAME: ghdocs-staging
44+
SLOT_NAME: canary
2745

2846
steps:
29-
- name: 'No-op'
47+
- name: 'Az CLI login'
48+
uses: azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf
49+
with:
50+
creds: ${{ secrets.PROD_AZURE_CREDENTIALS }}
51+
52+
- name: 'Docker login'
53+
uses: azure/docker-login@81744f9799e7eaa418697cb168452a2882ae844a
54+
with:
55+
login-server: ${{ secrets.NONPROD_REGISTRY_SERVER }}
56+
username: ${{ secrets.NONPROD_REGISTRY_USERNAME }}
57+
password: ${{ secrets.NONPROD_REGISTRY_PASSWORD }}
58+
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25
61+
62+
- name: Check out repo
63+
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
64+
with:
65+
ref: ${{ env.COMMIT_REF }}
66+
# To prevent issues with cloning early access content later
67+
persist-credentials: 'false'
68+
lfs: 'true'
69+
70+
- name: Check out LFS objects
71+
run: git lfs checkout
72+
73+
- name: 'Set env vars'
74+
run: |
75+
# Set APP_URL
76+
echo "APP_URL=${{ secrets.STAGING_APP_URL }}" >> $GITHUB_ENV
77+
# Image tag is unique to each workflow run so that it always triggers a new deployment
78+
echo "DOCKER_IMAGE=${{ secrets.NONPROD_REGISTRY_SERVER }}/${{ env.IMAGE_REPO }}:${{ env.COMMIT_REF }}-${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV
79+
80+
- name: Setup node
81+
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
82+
with:
83+
node-version: '16.15.0'
84+
cache: npm
85+
86+
- name: Clone docs-early-access
87+
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
88+
with:
89+
repository: github/docs-early-access
90+
token: ${{ secrets.DOCUBOT_REPO_PAT }}
91+
path: docs-early-access
92+
ref: main
93+
94+
- name: Merge docs-early-access repo's folders
95+
run: .github/actions-scripts/merge-early-access.sh
96+
97+
- name: 'Build and push image'
98+
uses: docker/build-push-action@7f9d37fa544684fb73bfe4835ed7214c255ce02b
99+
with:
100+
context: .
101+
push: true
102+
target: production
103+
tags: ${{ env.DOCKER_IMAGE }}
104+
build-args: |
105+
BUILD_SHA=${{ env.COMMIT_REF }}
106+
107+
- name: 'Update docker-compose.staging.yaml template file'
108+
run: |
109+
sed 's|#{IMAGE}#|${{ env.DOCKER_IMAGE }}|g' docker-compose.staging.tmpl.yaml > docker-compose.staging.yaml
110+
111+
- name: 'Apply updated docker-compose.staging.yaml config to deployment slot'
112+
run: |
113+
az webapp config container set --multicontainer-config-type COMPOSE --multicontainer-config-file docker-compose.staging.yaml --slot ${{ env.SLOT_NAME }} -n ${{ env.APP_SERVICE_NAME }} -g ${{ env.RESOURCE_GROUP_NAME }}
114+
115+
# Watch deployment slot instances to see when all the instances are ready
116+
- name: Check that deployment slot is ready
117+
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
118+
env:
119+
CHECK_INTERVAL: 10000
120+
with:
121+
script: |
122+
const { execSync } = require('child_process')
123+
124+
const slotName = process.env.SLOT_NAME
125+
const appServiceName = process.env.APP_SERVICE_NAME
126+
const resourceGroupName = process.env.RESOURCE_GROUP_NAME
127+
128+
const getStatesForSlot = (slot, appService, resourceGroup) => {
129+
return JSON.parse(
130+
execSync(
131+
`az webapp list-instances --slot ${slot} --query "[].state" -n ${appService} -g ${resourceGroup}`,
132+
{ encoding: 'utf8' }
133+
)
134+
)
135+
}
136+
137+
let hasStopped = false
138+
const waitDuration = parseInt(process.env.CHECK_INTERVAL, 10) || 10000
139+
async function doCheck() {
140+
const states = getStatesForSlot(slotName, appServiceName, resourceGroupName)
141+
console.log(`Instance states:`, states)
142+
143+
// We must wait until at-least 1 instance has STOPPED to know we're looking at the "next" deployment and not the "previous" one
144+
// That way we don't immediately succeed just because all the previous instances were READY
145+
if (!hasStopped) {
146+
hasStopped = states.some((s) => s === 'STOPPED')
147+
}
148+
149+
const isAllReady = states.every((s) => s === 'READY')
150+
151+
if (hasStopped && isAllReady) {
152+
process.exit(0) // success
153+
}
154+
155+
console.log(`checking again in ${waitDuration}ms`)
156+
setTimeout(doCheck, waitDuration)
157+
}
158+
159+
doCheck()
160+
161+
- name: 'Swap deployment slot to production'
30162
run: |
31-
echo "No-op"
163+
az webapp deployment slot swap --slot ${{ env.SLOT_NAME }} --target-slot production -n ${{ env.APP_SERVICE_NAME }} -g ${{ env.RESOURCE_GROUP_NAME }}

.github/workflows/browser-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
run: git lfs checkout
4141

4242
- name: Setup Node
43-
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561
43+
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
4444
with:
45-
node-version: 16.15.x
45+
node-version: '16.15.0'
4646
cache: npm
4747

4848
- name: Install dependencies

.github/workflows/check-all-english-links.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
- name: Check out repo's default branch
2929
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
3030
- name: Setup Node
31-
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561
31+
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
3232
with:
33-
node-version: 16.15.x
33+
node-version: '16.15.0'
3434
cache: npm
3535

3636
- name: Install dependencies
@@ -53,6 +53,9 @@ jobs:
5353
DISABLE_RENDER_CACHING: true
5454
# We don't want or need the changelog entries in this context.
5555
CHANGELOG_DISABLED: true
56+
# The default is 10s. But because this runs overnight, we can
57+
# be a lot more patient.
58+
REQUEST_TIMEOUT: 20000
5659
run: |
5760
node server.mjs &
5861
sleep 5

0 commit comments

Comments
 (0)