Skip to content

Commit 48c6e6f

Browse files
authored
Merge branch 'main' into amit-e-patch-2
2 parents 3f7ebf0 + b12064f commit 48c6e6f

144 files changed

Lines changed: 862 additions & 1643 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env node
2+
3+
import parsePrUrl from '../../script/deployment/parse-pr-url.js'
4+
import getOctokit from '../../script/helpers/github.js'
5+
import deployToStaging from '../../script/deployment/deploy-to-staging.js'
6+
7+
const { GITHUB_TOKEN, HEROKU_API_TOKEN } = process.env
8+
9+
// Exit if GitHub Actions PAT is not found
10+
if (!GITHUB_TOKEN) {
11+
throw new Error('You must supply a GITHUB_TOKEN environment variable!')
12+
}
13+
14+
// Exit if Heroku API token is not found
15+
if (!HEROKU_API_TOKEN) {
16+
throw new Error('You must supply a HEROKU_API_TOKEN environment variable!')
17+
}
18+
19+
// This helper uses the `GITHUB_TOKEN` implicitly!
20+
// We're using our usual version of Octokit vs. the provided `github`
21+
// instance to avoid versioning discrepancies.
22+
const octokit = getOctokit()
23+
24+
const { RUN_ID, PR_URL, SOURCE_BLOB_URL, CONTEXT_NAME, ACTIONS_RUN_LOG, HEAD_SHA } = process.env
25+
if (!RUN_ID) {
26+
throw new Error('$RUN_ID not set')
27+
}
28+
if (!PR_URL) {
29+
throw new Error('$PR_URL not set')
30+
}
31+
if (!SOURCE_BLOB_URL) {
32+
throw new Error('$SOURCE_BLOB_URL not set')
33+
}
34+
if (!CONTEXT_NAME) {
35+
throw new Error('$CONTEXT_NAME not set')
36+
}
37+
if (!ACTIONS_RUN_LOG) {
38+
throw new Error('$ACTIONS_RUN_LOG not set')
39+
}
40+
if (!HEAD_SHA) {
41+
throw new Error('$HEAD_SHA not set')
42+
}
43+
44+
const { owner, repo, pullNumber } = parsePrUrl(PR_URL)
45+
if (!owner || !repo || !pullNumber) {
46+
throw new Error(
47+
`'pullRequestUrl' input must match URL format 'https://github.com/github/(docs|docs-internal)/pull/123' but was '${PR_URL}'`
48+
)
49+
}
50+
51+
const { data: pullRequest } = await octokit.pulls.get({
52+
owner,
53+
repo,
54+
pull_number: pullNumber,
55+
})
56+
57+
await deployToStaging({
58+
octokit,
59+
pullRequest,
60+
forceRebuild: false,
61+
// These parameters will ONLY be set by Actions
62+
sourceBlobUrl: SOURCE_BLOB_URL,
63+
runId: RUN_ID,
64+
})
65+
66+
await octokit.repos.createCommitStatus({
67+
owner,
68+
repo,
69+
sha: HEAD_SHA,
70+
context: CONTEXT_NAME,
71+
state: 'success',
72+
description: 'Successfully deployed! See logs.',
73+
target_url: ACTIONS_RUN_LOG,
74+
})
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env node
2+
3+
import parsePrUrl from '../../script/deployment/parse-pr-url.js'
4+
import getOctokit from '../../script/helpers/github.js'
5+
import undeployFromStaging from '../../script/deployment/undeploy-from-staging.js'
6+
7+
const { GITHUB_TOKEN, HEROKU_API_TOKEN } = process.env
8+
9+
// Exit if GitHub Actions PAT is not found
10+
if (!GITHUB_TOKEN) {
11+
throw new Error('You must supply a GITHUB_TOKEN environment variable!')
12+
}
13+
14+
// Exit if Heroku API token is not found
15+
if (!HEROKU_API_TOKEN) {
16+
throw new Error('You must supply a HEROKU_API_TOKEN environment variable!')
17+
}
18+
19+
// This helper uses the `GITHUB_TOKEN` implicitly!
20+
// We're using our usual version of Octokit vs. the provided `github`
21+
// instance to avoid versioning discrepancies.
22+
const octokit = getOctokit()
23+
24+
const { RUN_ID, PR_URL } = process.env
25+
26+
if (!RUN_ID) {
27+
throw new Error('$RUN_ID not set')
28+
}
29+
if (!PR_URL) {
30+
throw new Error('$PR_URL not set')
31+
}
32+
33+
const { owner, repo, pullNumber } = parsePrUrl(PR_URL)
34+
if (!owner || !repo || !pullNumber) {
35+
throw new Error(
36+
`'pullRequestUrl' input must match URL format 'https://github.com/github/(docs|docs-internal)/pull/123' but was '${PR_URL}'`
37+
)
38+
}
39+
40+
const { data: pullRequest } = await octokit.pulls.get({
41+
owner,
42+
repo,
43+
pull_number: pullNumber,
44+
})
45+
46+
await undeployFromStaging({
47+
octokit,
48+
pullRequest: pullRequest,
49+
runId: RUN_ID,
50+
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ concurrency:
2121
jobs:
2222
build-and-deploy:
2323
if: ${{ github.repository == 'github/docs-internal'}}
24-
runs-on: ubuntu-latest
24+
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
2525
timeout-minutes: 15
2626
steps:
2727
- name: Check out repo

.github/workflows/staging-deploy-pr.yml

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ jobs:
6767
BUILD_ACTIONS_RUN_ID: ${{ env.BUILD_ACTIONS_RUN_ID }}
6868
with:
6969
script: |
70+
71+
// Curious about what version of node you get
72+
console.log('Node version:', process.version)
73+
7074
// In order to find out the PR info for a forked repo, we must query
7175
// the API for more info based on the originating workflow run
7276
const { BUILD_ACTIONS_RUN_ID } = process.env
@@ -482,12 +486,8 @@ jobs:
482486
- name: Install dependencies
483487
run: npm ci
484488

485-
- name: Install one-off development-only dependencies
486-
run: npm install --no-save --include=optional esm
487-
488489
- name: Deploy
489490
id: deploy
490-
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
491491
env:
492492
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
493493
HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }}
@@ -499,69 +499,8 @@ jobs:
499499
ACTIONS_RUN_LOG: ${{ env.ACTIONS_RUN_LOG }}
500500
HEAD_SHA: ${{ needs.pr-metadata.outputs.head_sha }}
501501
ALLOWED_POLLING_FAILURES_PER_PHASE: '15'
502-
with:
503-
script: |
504-
const { GITHUB_TOKEN, HEROKU_API_TOKEN } = process.env
505-
506-
// Exit if GitHub Actions PAT is not found
507-
if (!GITHUB_TOKEN) {
508-
throw new Error('You must supply a GITHUB_TOKEN environment variable!')
509-
}
510-
511-
// Exit if Heroku API token is not found
512-
if (!HEROKU_API_TOKEN) {
513-
throw new Error('You must supply a HEROKU_API_TOKEN environment variable!')
514-
}
515-
516-
// Workaround to allow us to load ESM files with `require(...)`
517-
const esm = require('esm')
518-
require = esm({})
519-
520-
const { default: parsePrUrl } = require('./script/deployment/parse-pr-url')
521-
const { default: getOctokit } = require('./script/helpers/github')
522-
const { default: deployToStaging } = require('./script/deployment/deploy-to-staging')
523-
524-
// This helper uses the `GITHUB_TOKEN` implicitly!
525-
// We're using our usual version of Octokit vs. the provided `github`
526-
// instance to avoid versioning discrepancies.
527-
const octokit = getOctokit()
528-
529-
try {
530-
const { PR_URL, SOURCE_BLOB_URL, CONTEXT_NAME, ACTIONS_RUN_LOG, HEAD_SHA } = process.env
531-
const { owner, repo, pullNumber } = parsePrUrl(PR_URL)
532-
if (!owner || !repo || !pullNumber) {
533-
throw new Error(`'pullRequestUrl' input must match URL format 'https://github.com/github/(docs|docs-internal)/pull/123' but was '${PR_URL}'`)
534-
}
535-
536-
const { data: pullRequest } = await octokit.pulls.get({
537-
owner,
538-
repo,
539-
pull_number: pullNumber
540-
})
541-
542-
await deployToStaging({
543-
octokit,
544-
pullRequest,
545-
forceRebuild: false,
546-
// These parameters will ONLY be set by Actions
547-
sourceBlobUrl: SOURCE_BLOB_URL,
548-
runId: context.runId
549-
})
550-
551-
await github.repos.createCommitStatus({
552-
owner,
553-
repo,
554-
sha: HEAD_SHA,
555-
context: CONTEXT_NAME,
556-
state: 'success',
557-
description: 'Successfully deployed! See logs.',
558-
target_url: ACTIONS_RUN_LOG
559-
})
560-
} catch (error) {
561-
console.error(`Failed to deploy to staging: ${error.message}`)
562-
console.error(error)
563-
throw error
564-
}
502+
RUN_ID: ${{ github.run_id }}
503+
run: .github/actions-scripts/staging-deploy.js
565504

566505
- name: Mark the deployment as inactive if timed out
567506
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d

.github/workflows/staging-undeploy-pr.yml

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -69,51 +69,13 @@ jobs:
6969
- name: Install dependencies
7070
run: npm ci
7171

72-
- name: Install one-off development-only dependencies
73-
run: npm install --no-save --include=optional esm
74-
7572
- name: Undeploy
76-
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
7773
env:
7874
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7975
HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }}
80-
with:
81-
script: |
82-
const { GITHUB_TOKEN, HEROKU_API_TOKEN } = process.env
83-
84-
// Exit if GitHub Actions PAT is not found
85-
if (!GITHUB_TOKEN) {
86-
throw new Error('You must supply a GITHUB_TOKEN environment variable!')
87-
}
88-
89-
// Exit if Heroku API token is not found
90-
if (!HEROKU_API_TOKEN) {
91-
throw new Error('You must supply a HEROKU_API_TOKEN environment variable!')
92-
}
93-
94-
// Workaround to allow us to load ESM files with `require(...)`
95-
const esm = require('esm')
96-
require = esm({})
97-
98-
const { default: getOctokit } = require('./script/helpers/github')
99-
const { default: undeployFromStaging } = require('./script/deployment/undeploy-from-staging')
100-
101-
// This helper uses the `GITHUB_TOKEN` implicitly!
102-
// We're using our usual version of Octokit vs. the provided `github`
103-
// instance to avoid versioning discrepancies.
104-
const octokit = getOctokit()
105-
106-
try {
107-
await undeployFromStaging({
108-
octokit,
109-
pullRequest: context.payload.pull_request,
110-
runId: context.runId
111-
})
112-
} catch (error) {
113-
console.error(`Failed to undeploy from staging: ${error.message}`)
114-
console.error(error)
115-
throw error
116-
}
76+
RUN_ID: ${{ github.run_id }}
77+
PR_URL: ${{ github.event.pull_request.html_url }}
78+
run: .github/actions-scripts/staging-undeploy.js
11779

11880
- if: ${{ always() }}
11981
name: Remove the label from the PR to unblock deployment

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GitHub Docs <!-- omit in toc -->
1+
# GitHub Docs <!-- omit in toc -->
22

33
This repository contains the documentation website code and Markdown source files for [docs.github.com](https://docs.github.com).
44

components/article/ArticlePage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { MarkdownContent } from 'components/ui/MarkdownContent'
1515
import { Lead } from 'components/ui/Lead'
1616
import { ArticleGridLayout } from './ArticleGridLayout'
1717
import { PlatformPicker } from 'components/article/PlatformPicker'
18+
import { ToolPicker } from 'components/article/ToolPicker'
1819

1920
// Mapping of a "normal" article to it's interactive counterpart
2021
const interactiveAlternatives: Record<string, { href: string }> = {
@@ -52,6 +53,7 @@ export const ArticlePage = () => {
5253
contributor,
5354
permissions,
5455
includesPlatformSpecificContent,
56+
includesToolSpecificContent,
5557
product,
5658
miniTocItems,
5759
currentLearningTrack,
@@ -111,6 +113,7 @@ export const ArticlePage = () => {
111113
)}
112114

113115
{includesPlatformSpecificContent && <PlatformPicker variant="underlinenav" />}
116+
{includesToolSpecificContent && <ToolPicker variant="underlinenav" />}
114117

115118
{product && (
116119
<Callout

components/article/PlatformPicker.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ const platforms = [
1212
{ id: 'linux', label: 'Linux' },
1313
]
1414

15+
// Nota bene: platform === os
16+
1517
// Imperatively modify article content to show only the selected platform
1618
// find all platform-specific *block* elements and hide or show as appropriate
17-
// example: {% mac } block content {% mac %}
19+
// example: {% mac %} block content {% endmac %}
1820
function showPlatformSpecificContent(platform: string) {
1921
const markdowns = Array.from(document.querySelectorAll<HTMLElement>('.extended-markdown'))
2022
markdowns

0 commit comments

Comments
 (0)