Skip to content

Commit c535420

Browse files
authored
decorate script fix (github#18201)
1 parent beef176 commit c535420

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

.github/allowed-actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ module.exports = [
3939
"repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d",
4040
"someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd",
4141
"tjenkinson/gh-action-auto-merge-dependency-updates@4d7756c04d9d999c5968697a621b81c47f533d61",
42-
"EndBug/add-and-commit@9358097a71ad9fb9e2f9624c6098c89193d83575",
42+
"EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519",
4343
"dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58",
4444
];

.github/workflows/openapi-decorate.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ jobs:
2525
run: script/rest/update-files.js --decorate-only
2626

2727
- name: Check in the decorated files
28-
uses: EndBug/add-and-commit@9358097a71ad9fb9e2f9624c6098c89193d83575
28+
uses: EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519
2929
with:
3030
# The arguments for the `git add` command
3131
add: 'lib/rest/static/decorated'
3232

3333
# The message for the commit
3434
message: 'Add decorated OpenAPI schema files'
35-
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged

script/rest/update-files.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,23 @@ async function decorate () {
9191
}, {})
9292

9393
for (const [schemaName, schema] of Object.entries(dereferencedSchemas)) {
94-
// munge OpenAPI definitions object in an array of operations objects
95-
const operations = await getOperations(schema)
96-
97-
// process each operation, asynchronously rendering markdown and stuff
98-
await Promise.all(operations.map(operation => operation.process()))
99-
100-
const filename = path.join(decoratedPath, `${schemaName}.json`)
101-
.replace('.deref', '')
102-
// write processed operations to disk
103-
fs.writeFileSync(filename, JSON.stringify(operations, null, 2))
104-
105-
console.log('Wrote', path.relative(process.cwd(), filename))
94+
try {
95+
// munge OpenAPI definitions object in an array of operations objects
96+
const operations = await getOperations(schema)
97+
98+
// process each operation, asynchronously rendering markdown and stuff
99+
await Promise.all(operations.map(operation => operation.process()))
100+
101+
const filename = path.join(decoratedPath, `${schemaName}.json`)
102+
.replace('.deref', '')
103+
// write processed operations to disk
104+
fs.writeFileSync(filename, JSON.stringify(operations, null, 2))
105+
106+
console.log('Wrote', path.relative(process.cwd(), filename))
107+
} catch (error) {
108+
console.error(error)
109+
console.log('🐛 Whoops! It looks like the decorator script wasn\'t able to parse the dereferenced schema. A recent change may not yet be supported by the decorator. Please reach out in the #docs-engineering slack channel for help.')
110+
process.exit(1)
111+
}
106112
}
107113
}

0 commit comments

Comments
 (0)