Skip to content

Commit 9c778fc

Browse files
committed
Add workflowCall function to sync.ts
1 parent 24196e6 commit 9c778fc

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

‎pr-checks/sync.ts‎

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,29 @@ function generateValidationJobs(
698698
};
699699
}
700700

701+
/**
702+
* Constructs the body of a job that calls another workflow.
703+
*
704+
* @param jobName The friendly name of the job.
705+
* @param workflowBaseName The base name of the workflow file to call.
706+
* @param inputs Optionally, the inputs for the workflow.
707+
*/
708+
function workflowCall(
709+
jobName: string,
710+
workflowBaseName: string,
711+
inputs?: Record<string, string>,
712+
) {
713+
return {
714+
name: jobName,
715+
permissions: {
716+
contents: "read",
717+
"security-events": "read",
718+
},
719+
uses: `./.github/workflows/${workflowBaseName}.yml`,
720+
with: inputs,
721+
};
722+
}
723+
701724
/**
702725
* Main entry point for the sync script.
703726
*/
@@ -818,15 +841,11 @@ function main(): void {
818841
checkWith[inputName] = `\${{ inputs.${inputName} }}`;
819842
}
820843

821-
jobs[checkName] = {
822-
name: specification.name,
823-
permissions: {
824-
contents: "read",
825-
"security-events": "read",
826-
},
827-
uses: `./.github/workflows/__${checkName}.yml`,
828-
with: checkWith,
829-
};
844+
jobs[checkName] = workflowCall(
845+
specification.name,
846+
`__${checkName}`,
847+
checkWith,
848+
);
830849
}
831850

832851
const collectionWorkflow = {

0 commit comments

Comments
 (0)