Skip to content

Commit ea24da3

Browse files
committed
Generate one workflow with all jobs
1 parent 63781c6 commit ea24da3

3 files changed

Lines changed: 81 additions & 7 deletions

File tree

‎.github/workflows/__pr.yml‎

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/pr-checks.yml‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ name: PR Checks
22

33
on:
44
push:
5-
pull_request:
6-
merge_group:
7-
types: [checks_requested]
85
workflow_dispatch:
6+
workflow_call:
97

108
concurrency:
11-
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
9+
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_call' }}
1210
group: ${{ github.workflow }}-${{ github.ref }}
1311

1412
defaults:

‎pr-checks/sync.ts‎

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,45 @@ function main(): void {
737737

738738
console.log(`Found ${checkFiles.length} check specification(s).`);
739739

740+
let allInputs: Record<string, WorkflowInput> = {};
741+
742+
const initialChecksJob = workflowCall("Initial checks", "pr-checks");
743+
744+
const cron = new yaml.Scalar("0 5 * * *");
745+
cron.type = yaml.Scalar.QUOTE_SINGLE;
746+
747+
const checkWorkflow = {
748+
name: `PR Checks`,
749+
env: {
750+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}",
751+
GO111MODULE: "auto",
752+
},
753+
on: {
754+
push: {
755+
branches: ["main", "releases/v*"],
756+
},
757+
pull_request: {},
758+
merge_group: {
759+
types: ["checks_requested"],
760+
},
761+
schedule: [{ cron }],
762+
workflow_dispatch: {
763+
inputs: {},
764+
},
765+
workflow_call: {
766+
inputs: {},
767+
},
768+
},
769+
defaults: {
770+
run: {
771+
shell: "bash",
772+
},
773+
},
774+
jobs: {
775+
"pr-checks": initialChecksJob,
776+
},
777+
};
778+
740779
const collections: Record<
741780
string,
742781
Array<{
@@ -781,9 +820,6 @@ function main(): void {
781820
extraGroupName += `-\${{inputs.${inputName}}}`;
782821
}
783822

784-
const cron = new yaml.Scalar("0 5 * * *");
785-
cron.type = yaml.Scalar.QUOTE_SINGLE;
786-
787823
const workflow = {
788824
name: `PR Check - ${checkSpecification.name}`,
789825
env: {
@@ -826,6 +862,12 @@ function main(): void {
826862
writeYaml(outputPath, workflow);
827863
}
828864

865+
checkWorkflow.on.workflow_call.inputs = allInputs;
866+
checkWorkflow.on.workflow_dispatch.inputs = allInputs;
867+
868+
const mainOutputPath = path.join(OUTPUT_DIR, `__pr.yml`);
869+
writeYaml(mainOutputPath, checkWorkflow);
870+
829871
// Write workflow files for collections.
830872
for (const collectionName of Object.keys(collections)) {
831873
const jobs: Record<string, any> = {};

0 commit comments

Comments
 (0)