Skip to content

Commit 9d148a3

Browse files
authored
repo sync
2 parents 30efce1 + 6d14aea commit 9d148a3

5 files changed

Lines changed: 31651 additions & 16282 deletions

File tree

content/actions/reference/context-and-expression-syntax-for-github-actions.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,27 +186,27 @@ jobs:
186186
steps:
187187
- name: Dump GitHub context
188188
env:
189-
GITHUB_CONTEXT: ${{ toJson(github) }}
189+
GITHUB_CONTEXT: ${{ toJSON(github) }}
190190
run: echo "$GITHUB_CONTEXT"
191191
- name: Dump job context
192192
env:
193-
JOB_CONTEXT: ${{ toJson(job) }}
193+
JOB_CONTEXT: ${{ toJSON(job) }}
194194
run: echo "$JOB_CONTEXT"
195195
- name: Dump steps context
196196
env:
197-
STEPS_CONTEXT: ${{ toJson(steps) }}
197+
STEPS_CONTEXT: ${{ toJSON(steps) }}
198198
run: echo "$STEPS_CONTEXT"
199199
- name: Dump runner context
200200
env:
201-
RUNNER_CONTEXT: ${{ toJson(runner) }}
201+
RUNNER_CONTEXT: ${{ toJSON(runner) }}
202202
run: echo "$RUNNER_CONTEXT"
203203
- name: Dump strategy context
204204
env:
205-
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
205+
STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
206206
run: echo "$STRATEGY_CONTEXT"
207207
- name: Dump matrix context
208208
env:
209-
MATRIX_CONTEXT: ${{ toJson(matrix) }}
209+
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
210210
run: echo "$MATRIX_CONTEXT"
211211
```
212212
{% endraw %}
@@ -348,7 +348,7 @@ The value for `array` can be an array or a string. All values in `array` are con
348348

349349
`join(github.event.issue.labels.*.name, ', ')` may return 'bug, help wanted'
350350

351-
#### toJson
351+
#### toJSON
352352

353353
`toJSON(value)`
354354

@@ -358,13 +358,13 @@ Returns a pretty-print JSON representation of `value`. You can use this function
358358

359359
`toJSON(job)` might return `{ "status": "Success" }`
360360

361-
#### fromJson
361+
#### fromJSON
362362

363363
`fromJSON(value)`
364364

365-
Returns a JSON object for `value`. You can use this function to provide a JSON object as an evaluated expression.
365+
Returns a JSON object or JSON data type for `value`. You can use this function to provide a JSON object as an evaluated expression or to convert environment variables from a string.
366366

367-
##### Example
367+
##### Example returning a JSON object
368368

369369
This workflow sets a JSON matrix in one job, and passes it to the next job using an output and `fromJSON`.
370370

@@ -384,12 +384,33 @@ jobs:
384384
needs: job1
385385
runs-on: ubuntu-latest
386386
strategy:
387-
matrix: ${{fromJson(needs.job1.outputs.matrix)}}
387+
matrix: ${{fromJSON(needs.job1.outputs.matrix)}}
388388
steps:
389389
- run: build
390390
```
391391
{% endraw %}
392392

393+
##### Example returning a JSON data type
394+
395+
This workflow uses `fromJSON` to convert environment variables from a string to a Boolean or integer.
396+
397+
{% raw %}
398+
```yaml
399+
name: print
400+
on: push
401+
env:
402+
continue: true
403+
time: 3
404+
jobs:
405+
job1:
406+
runs-on: ubuntu-latest
407+
steps:
408+
- continue-on-error: ${{ fromJSON(env.continue) }}
409+
timeout-minutes: ${{ fromJSON(env.time) }}
410+
run: echo ...
411+
```
412+
{% endraw %}
413+
393414
#### hashFiles
394415

395416
`hashFiles(path)`

lib/redirects/precompile.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
const patterns = require('../patterns')
21
const { latest } = require('../enterprise-server-releases')
3-
const getOldPathsFromPermalink = require('../redirects/get-old-paths-from-permalink')
42
const getDocsPathFromDevPath = require('../redirects/get-docs-path-from-developer-path')
53
const DEVELOPER_ROUTES = require('../redirects/static/developer-docs-routes-for-supported-versions')
6-
const ARCHIVED_ROUTES = require('../redirects/static/archived-routes-from-213-to-217')
74

85
// This function runs at server warmup and precompiles possible redirect routes.
96
// It outputs them in key-value pairs within a neat Javascript object: { oldPath: newPath }
@@ -14,26 +11,7 @@ module.exports = function precompileRedirects (pageList, pageMap) {
1411
// create backwards-compatible old paths for page permalinks and frontmatter redirects
1512
pageList.forEach(page => Object.assign(allRedirects, page.buildRedirects()))
1613

17-
// 2. REDIRECTS FOR ARCHIVED ROUTES FROM 2.13 TO 2.17
18-
// Starting with 2.18, we updated the archival script to create stubbed HTML redirect files,
19-
// so those files do the heavy lifting. The handling here is only for blanket redirects
20-
// (like /articles -> /github) between 2.13 and 2.17. This works by creating possible
21-
// old/incoming paths from the archived routes JSON. Frontmatter redirects were lost
22-
// for 2.13-2.17, but the archived middleware tries to find fallbacks.
23-
ARCHIVED_ROUTES.forEach(archivedRoute => {
24-
const languageFromPath = archivedRoute.match(patterns.getLanguageCode)[1]
25-
const versionFromPath = archivedRoute.match(patterns.getEnterpriseVersionNumber)[1]
26-
27-
// get an array of possible old paths, e.g., /desktop/guides/ from /desktop/
28-
const possibleOldPaths = getOldPathsFromPermalink(archivedRoute, languageFromPath, versionFromPath)
29-
30-
// for each old path, add a redirect to the current route
31-
possibleOldPaths.forEach(oldPath => {
32-
allRedirects[oldPath] = archivedRoute
33-
})
34-
})
35-
36-
// 3. DEVELOPER ROUTES FOR CURRENTLY SUPPORTED VERSIONS
14+
// 2. DEVELOPER ROUTES FOR CURRENTLY SUPPORTED VERSIONS
3715
// From the list of developer docs routes, create new docs.github.com-style paths.
3816
// Note that the list only includes supported enterprise paths up to 2.21, which is
3917
// the last version that was available on developer.github.com before the migration.

0 commit comments

Comments
 (0)