Skip to content

Commit 6ba4342

Browse files
committed
Allow setting permissions for workflowCall
1 parent c771732 commit 6ba4342

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎.github/workflows/__pr.yml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pr-checks/sync.ts‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -709,16 +709,20 @@ function generateValidationJobs(
709709
function workflowCall(
710710
jobName: string,
711711
workflowBaseName: string,
712-
inputs?: Record<string, string>,
712+
options?: {
713+
inputs?: Record<string, string>;
714+
permissions?: Record<string, "read" | "write">;
715+
},
713716
) {
714717
return {
715718
name: jobName,
716719
permissions: {
717720
contents: "read",
718721
"security-events": "read",
722+
...options?.permissions,
719723
},
720724
uses: `./.github/workflows/${workflowBaseName}.yml`,
721-
with: inputs,
725+
with: options?.inputs,
722726
};
723727
}
724728

@@ -740,7 +744,9 @@ function main(): void {
740744

741745
let allInputs: Record<string, WorkflowInput> = {};
742746

743-
const initialChecksJob = workflowCall("Initial checks", "pr-checks");
747+
const initialChecksJob = workflowCall("Initial checks", "pr-checks", {
748+
permissions: { "security-events": "write" },
749+
});
744750

745751
const cron = new yaml.Scalar("0 5 * * *");
746752
cron.type = yaml.Scalar.QUOTE_SINGLE;
@@ -856,11 +862,9 @@ function main(): void {
856862
checkWith[inputName] = `\${{ inputs.${inputName} }}`;
857863
}
858864

859-
jobs[checkName] = workflowCall(
860-
specification.name,
861-
`__${checkName}`,
862-
checkWith,
863-
);
865+
jobs[checkName] = workflowCall(specification.name, `__${checkName}`, {
866+
inputs: checkWith,
867+
});
864868
}
865869

866870
const collectionWorkflow = {

0 commit comments

Comments
 (0)