Skip to content

Commit cb36bd6

Browse files
authored
Merge branch 'main' into patch-2
2 parents 5cae791 + 066d373 commit cb36bd6

24 files changed

Lines changed: 575 additions & 167 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env node
2+
3+
import createStagingAppName from '../../script/deployment/create-staging-app-name.js'
4+
import * as github from '@actions/github'
5+
import { setOutput } from '@actions/core'
6+
7+
const context = github.context
8+
9+
const githubToken = process.env.GITHUB_TOKEN
10+
if (!githubToken) {
11+
throw new Error(`GITHUB_TOKEN environment variable not set`)
12+
}
13+
14+
const stagingPrefix = createStagingAppName({
15+
repo: context.payload.repository.name,
16+
pullNumber: context.payload.number,
17+
branch: context.payload.pull_request.head.ref,
18+
})
19+
20+
const octokit = github.getOctokit(githubToken)
21+
22+
const response = await octokit.rest.repos.compareCommits({
23+
owner: context.repo.owner,
24+
repo: context.payload.repository.name,
25+
base: context.payload.pull_request.base.sha,
26+
head: context.payload.pull_request.head.sha,
27+
})
28+
29+
const { files } = response.data
30+
31+
let markdownTable =
32+
'| **Source** | **Staging** | **Production** | **What Changed** |\n|:----------- |:----------- |:----------- |:----------- |\n'
33+
34+
const pathPrefix = 'content/'
35+
const articleFiles = files.filter(
36+
({ filename }) => filename.startsWith(pathPrefix) && !filename.endsWith('/index.md')
37+
)
38+
for (const file of articleFiles) {
39+
const sourceUrl = file.blob_url
40+
const fileName = file.filename.slice(pathPrefix.length)
41+
const fileUrl = fileName.slice(0, fileName.lastIndexOf('.'))
42+
const stagingLink = `https://${stagingPrefix}.herokuapp.com/${fileUrl}`
43+
const productionLink = `https://docs.github.com/${fileUrl}`
44+
let markdownLine = ''
45+
46+
if (file.status === 'modified') {
47+
markdownLine = `| [content/${fileName}](${sourceUrl}) | [Modified](${stagingLink}) | [Original](${productionLink}) | |\n`
48+
} else if (file.status === 'added') {
49+
markdownLine = `| New file: [content/${fileName}](${sourceUrl}) | [Modified](${stagingLink}) | | |\n`
50+
}
51+
markdownTable += markdownLine
52+
}
53+
54+
setOutput('changesTable', markdownTable)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env node
2+
3+
import getOctokit from '../../script/helpers/github.js'
4+
import deployToProduction from '../../script/deployment/deploy-to-production.js'
5+
6+
const {
7+
GITHUB_TOKEN,
8+
HEROKU_API_TOKEN,
9+
HEROKU_PRODUCTION_APP_NAME,
10+
SOURCE_BLOB_URL,
11+
DELAY_FOR_PREBOOT,
12+
RUN_ID,
13+
} = process.env
14+
15+
// Exit if GitHub Actions PAT is not found
16+
if (!GITHUB_TOKEN) {
17+
throw new Error('You must supply a GITHUB_TOKEN environment variable!')
18+
}
19+
20+
// Exit if Heroku API token is not found
21+
if (!HEROKU_API_TOKEN) {
22+
throw new Error('You must supply a HEROKU_API_TOKEN environment variable!')
23+
}
24+
25+
// Exit if Heroku App name is not found
26+
if (!HEROKU_PRODUCTION_APP_NAME) {
27+
throw new Error('You must supply a HEROKU_PRODUCTION_APP_NAME environment variable!')
28+
}
29+
30+
if (!RUN_ID) {
31+
throw new Error('$RUN_ID not set')
32+
}
33+
34+
// This helper uses the `GITHUB_TOKEN` implicitly!
35+
// We're using our usual version of Octokit vs. the provided `github`
36+
// instance to avoid versioning discrepancies.
37+
const octokit = getOctokit()
38+
39+
try {
40+
await deployToProduction({
41+
octokit,
42+
includeDelayForPreboot: DELAY_FOR_PREBOOT !== 'false',
43+
// These parameters will ONLY be set by Actions
44+
sourceBlobUrl: SOURCE_BLOB_URL,
45+
runId: RUN_ID,
46+
})
47+
} catch (error) {
48+
console.error(`Failed to deploy to production: ${error.message}`)
49+
console.error(error)
50+
throw error
51+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env node
2+
3+
import purgeEdgeCache from '../../script/deployment/purge-edge-cache.js'
4+
5+
try {
6+
await purgeEdgeCache()
7+
} catch (error) {
8+
console.error(`Failed to purge the edge cache: ${error.message}`)
9+
console.error(error)
10+
throw error
11+
}

.github/workflows/content-changes-table-comment.yml

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,57 +49,12 @@ jobs:
4949
- name: Install temporary dependencies
5050
run: |
5151
npm install --no-save github-slugger
52-
npm install --no-save --include=optional esm
5352
5453
- name: Get changes table
55-
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
5654
id: changes
5755
env:
5856
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59-
with:
60-
script: |
61-
// Workaround to allow us to load ESM files with `require(...)`
62-
const esm = require('esm')
63-
require = esm({})
64-
65-
const { default: createStagingAppName } = require('./script/deployment/create-staging-app-name')
66-
67-
const stagingPrefix = createStagingAppName({
68-
repo: context.payload.repository.name,
69-
pullNumber: context.payload.number,
70-
branch: context.payload.pull_request.head.ref,
71-
})
72-
73-
const response = await github.repos.compareCommits({
74-
owner: context.repo.owner,
75-
repo: context.repo.repo,
76-
base: context.payload.pull_request.base.sha,
77-
head: context.payload.pull_request.head.sha
78-
})
79-
80-
const files = response.data.files
81-
82-
let markdownTable = '| **Source** | **Staging** | **Production** | **What Changed** |\n|:----------- |:----------- |:----------- |:----------- |\n'
83-
84-
const pathPrefix = 'content/'
85-
const articleFiles = files.filter(({ filename }) => filename.startsWith(pathPrefix) && !filename.endsWith('/index.md'))
86-
for (const file of articleFiles) {
87-
const sourceUrl = file.blob_url
88-
const fileName = file.filename.slice(pathPrefix.length)
89-
const fileUrl = fileName.slice(0, fileName.lastIndexOf('.'))
90-
const stagingLink = `https://${stagingPrefix}.herokuapp.com/${fileUrl}`
91-
const productionLink = `https://docs.github.com/${fileUrl}`
92-
let markdownLine = ''
93-
94-
if (file.status === 'modified') {
95-
markdownLine = `| [content/${fileName}](${sourceUrl}) | [Modified](${stagingLink}) | [Original](${productionLink}) | |\n`
96-
} else if (file.status === 'added') {
97-
markdownLine = `| New file: [content/${fileName}](${sourceUrl}) | [Modified](${stagingLink}) | | |\n`
98-
}
99-
markdownTable += markdownLine
100-
}
101-
102-
core.setOutput('changesTable', markdownTable)
57+
run: .github/actions-scripts/content-changes-table-comment.js
10358

10459
- name: Find content directory changes comment
10560
uses: peter-evans/find-comment@d2dae40ed151c634e4189471272b57e76ec19ba8

.github/workflows/create-translation-batch-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ jobs:
138138

139139
- name: Check in CSV report
140140
run: |
141-
mkdir -p log
142-
csvFile=log/${{ matrix.language_code }}-resets.csv
141+
mkdir -p translations/log
142+
csvFile=translations/log/${{ matrix.language_code }}-resets.csv
143143
script/i18n/report-reset-files.js --report-type=csv --language=${{ matrix.language_code }} --log-file=/tmp/batch.log > $csvFile
144144
git add -f $csvFile && git commit -m "Check in ${{ matrix.language }} CSV report" || echo "Nothing to commit"
145145

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

Lines changed: 4 additions & 71 deletions
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: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
24+
runs-on: ubuntu-latest
2525
timeout-minutes: 15
2626
steps:
2727
- name: Check out repo
@@ -129,12 +129,8 @@ jobs:
129129
-H 'Content-Type:' \
130130
--data-binary @app.tar.gz
131131
132-
- name: Install one-off development-only dependencies
133-
run: npm install --no-save --include=optional esm
134-
135132
- name: Deploy
136133
id: deploy
137-
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
138134
env:
139135
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140136
HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }}
@@ -144,56 +140,8 @@ jobs:
144140
SOURCE_BLOB_URL: ${{ steps.build-source.outputs.download_url }}
145141
DELAY_FOR_PREBOOT: 'true'
146142
ALLOWED_POLLING_FAILURES_PER_PHASE: '15'
147-
with:
148-
script: |
149-
const {
150-
GITHUB_TOKEN,
151-
HEROKU_API_TOKEN,
152-
HEROKU_PRODUCTION_APP_NAME,
153-
SOURCE_BLOB_URL,
154-
DELAY_FOR_PREBOOT
155-
} = process.env
156-
157-
// Exit if GitHub Actions PAT is not found
158-
if (!GITHUB_TOKEN) {
159-
throw new Error('You must supply a GITHUB_TOKEN environment variable!')
160-
}
161-
162-
// Exit if Heroku API token is not found
163-
if (!HEROKU_API_TOKEN) {
164-
throw new Error('You must supply a HEROKU_API_TOKEN environment variable!')
165-
}
166-
167-
// Exit if Heroku App name is not found
168-
if (!HEROKU_PRODUCTION_APP_NAME) {
169-
throw new Error('You must supply a HEROKU_PRODUCTION_APP_NAME environment variable!')
170-
}
171-
172-
// Workaround to allow us to load ESM files with `require(...)`
173-
const esm = require('esm')
174-
require = esm({})
175-
176-
const { default: getOctokit } = require('./script/helpers/github')
177-
const { default: deployToProduction } = require('./script/deployment/deploy-to-production')
178-
179-
// This helper uses the `GITHUB_TOKEN` implicitly!
180-
// We're using our usual version of Octokit vs. the provided `github`
181-
// instance to avoid versioning discrepancies.
182-
const octokit = getOctokit()
183-
184-
try {
185-
await deployToProduction({
186-
octokit,
187-
includeDelayForPreboot: DELAY_FOR_PREBOOT !== 'false',
188-
// These parameters will ONLY be set by Actions
189-
sourceBlobUrl: SOURCE_BLOB_URL,
190-
runId: context.runId
191-
})
192-
} catch (error) {
193-
console.error(`Failed to deploy to production: ${error.message}`)
194-
console.error(error)
195-
throw error
196-
}
143+
RUN_ID: ${{ github.run_id }}
144+
run: .github/actions-scripts/prod-deploy.js
197145

198146
- name: Mark the deployment as inactive if timed out
199147
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
@@ -227,26 +175,11 @@ jobs:
227175
console.log('⏲️ Deployment status: error - The deployment timed out...')
228176
229177
- name: Purge Fastly edge cache
230-
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
231178
env:
232179
FASTLY_TOKEN: ${{ secrets.FASTLY_TOKEN }}
233180
FASTLY_SERVICE_ID: ${{ secrets.FASTLY_SERVICE_ID }}
234181
FASTLY_SURROGATE_KEY: 'all-the-things'
235-
with:
236-
script: |
237-
// Workaround to allow us to load ESM files with `require(...)`
238-
const esm = require('esm')
239-
require = esm({})
240-
241-
const { default: purgeEdgeCache } = require('./script/deployment/purge-edge-cache')
242-
243-
try {
244-
await purgeEdgeCache()
245-
} catch (error) {
246-
console.error(`Failed to purge the edge cache: ${error.message}`)
247-
console.error(error)
248-
throw error
249-
}
182+
run: .github/actions-scripts/purge-fastly-edge-cache.js
250183

251184
- name: Send Slack notification if workflow failed
252185
uses: someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340

components/article/ToolPicker.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,15 @@ export const ToolPicker = ({ variant = 'subnav' }: Props) => {
8080
}
8181
}, [])
8282

83-
function onClickTool(tool: string) {
84-
setCurrentTool(tool)
83+
// Whenever the currentTool is changed, update the article content
84+
useEffect(() => {
8585
preserveAnchorNodePosition(document, () => {
86-
showToolSpecificContent(tool)
86+
showToolSpecificContent(currentTool)
8787
})
88+
}, [currentTool])
89+
90+
function onClickTool(tool: string) {
91+
setCurrentTool(tool)
8892
sendEvent({
8993
type: EventType.preference,
9094
preference_name: 'application',

content/actions/learn-github-actions/reusing-workflows.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Called workflows can access self-hosted runners from caller's context. This mean
7070
* Reusable workflows stored within a private repository can only be used by workflows within the same repository.
7171
* Any environment variables set in an `env` context defined at the workflow level in the caller workflow are not propagated to the called workflow. For more information about the `env` context, see "[Context and expression syntax for GitHub Actions](/actions/reference/context-and-expression-syntax-for-github-actions#env-context)."
7272
* You can't set the concurrency of a called workflow from the caller workflow. For more information about `jobs.<job_id>.concurrency`, see "[Workflow syntax for GitHub Actions](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idconcurrency)."
73+
* The `strategy` property is not supported in any job that calls a reusable workflow.
7374

7475
## Creating a reusable workflow
7576

0 commit comments

Comments
 (0)