Skip to content

Commit 89e21b6

Browse files
kweinmeisterNimJay
andauthored
ci: add option to generate one workflow (#2822)
* ci: add option to generate one workflow * Update .github/workflows/generate.js Co-authored-by: Nim Jayawardena <[email protected]> * Update .github/workflows/generate.js Co-authored-by: Nim Jayawardena <[email protected]> * docs: update contributing instructions Co-authored-by: Nim Jayawardena <[email protected]>
1 parent be12932 commit 89e21b6

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.github/workflows/generate.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ const fs = require('fs').promises;
1818

1919
async function main() {
2020
nunjucks.configure('.github/workflows', {autoescape: true});
21+
22+
// Optional filter to generate one workflow
23+
const specificWorkflowPath = process.argv.slice(2)[0];
24+
2125
for (const workflow of workflows) {
22-
const path = workflow;
23-
const name = workflow.split('/').join('-');
24-
const suite = name.split('-').join('_');
25-
const data = nunjucks.render('ci.yaml.njk', {path, name, suite});
26-
await fs.writeFile(`.github/workflows/${name}.yaml`, data);
26+
if (!specificWorkflowPath || specificWorkflowPath === workflow) {
27+
const path = workflow;
28+
const name = workflow.split('/').join('-');
29+
const suite = name.split('-').join('_');
30+
const data = nunjucks.render('ci.yaml.njk', {path, name, suite});
31+
await fs.writeFile(`.github/workflows/${name}.yaml`, data);
32+
}
2733
}
2834
}
2935

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ For new samples, a GitHub Actions workflow should be created to run your tests o
3030

3131
1. Add an entry to [.github/workflows/workflows.json](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/main/.github/workflows/workflows.json) matching the directory with your sample code.
3232

33-
1. From the root of the repo, generate a new workflow in the [workflows](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/main/.github/workflows) directory:
33+
1. From the root of the repo, generate a new workflow in the [workflows](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/main/.github/workflows) directory. You can specify a `path` to only generate the specific workflow, e.g. `cloud-tasks`. If the path is omitted, all workflows will be generated.
3434

35-
node .github/workflows/generate.js
35+
node .github/workflows/generate.js [path]
3636

3737
> **Note**
3838
> There are some existing samples that use an alternative CI system. It is recommended to use GitHub Actions for new samples, but these instructions are provided below for your reference.

0 commit comments

Comments
 (0)