Skip to content

Commit a85af80

Browse files
committed
Generate and write collections
1 parent 47671ab commit a85af80

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

pr-checks/sync.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,50 @@ function main(): void {
457457
writeYaml(outputPath, workflow);
458458
}
459459

460+
// Write workflow files for collections.
461+
for (const collectionName of Object.keys(collections)) {
462+
const jobs: Record<string, any> = {};
463+
let combinedInputs: Record<string, WorkflowInput> = {};
464+
465+
for (const check of collections[collectionName]) {
466+
const { checkName, specification, inputs: checkInputs } = check;
467+
const checkWith: Record<string, string> = {};
468+
469+
combinedInputs = { ...combinedInputs, ...checkInputs };
470+
471+
for (const inputName of Object.keys(checkInputs)) {
472+
checkWith[inputName] = "${{ inputs." + inputName + " }}";
473+
}
474+
475+
jobs[checkName] = {
476+
name: specification.name,
477+
permissions: {
478+
contents: "read",
479+
"security-events": "read",
480+
},
481+
uses: `./.github/workflows/__${checkName}.yml`,
482+
with: checkWith,
483+
};
484+
}
485+
486+
const collectionWorkflow = {
487+
name: `Manual Check - ${collectionName}`,
488+
env: {
489+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}",
490+
GO111MODULE: "auto",
491+
},
492+
on: {
493+
workflow_dispatch: {
494+
inputs: combinedInputs,
495+
},
496+
},
497+
jobs,
498+
};
499+
500+
const outputPath = path.join(OUTPUT_DIR, `__${collectionName}.yml`);
501+
writeYaml(outputPath, collectionWorkflow);
502+
}
503+
460504
console.log(
461505
`\nDone. Wrote ${checkFiles.length} workflow file(s) to ${OUTPUT_DIR}`,
462506
);

0 commit comments

Comments
 (0)