Skip to content

Commit 2213fa8

Browse files
committed
Add on: to workflow
1 parent 9bc565f commit 2213fa8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/package/on.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export type EventName = "push" | "pull_request" | "workflow_dispatch";
2+
3+
export type On =
4+
| EventName
5+
| EventName[]
6+
// TODO: implement
7+
| {
8+
push: {
9+
branches?: string[];
10+
};
11+
};

lib/package/workflow.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { Job } from "./job";
2+
import type { On } from "./on";
23
import type { Permissions } from "./permission";
34

45
export type WorkflowConfig = {
56
name: string;
7+
on: On;
68
permissions?: Permissions;
79
};
810

911
export class Workflow {
1012
private readonly _config: WorkflowConfig;
1113
private readonly _jobs: Record<string, Job> = {};
1214

13-
public constructor(name: string, config?: Omit<WorkflowConfig, "name">) {
15+
public constructor(name: string, config: Omit<WorkflowConfig, "name">) {
1416
this._config = { name, ...config };
1517
}
1618

@@ -23,7 +25,7 @@ export class Workflow {
2325
return {
2426
name: this._config.name,
2527
permissions: this._config.permissions,
26-
on: { push: {} }, // TODO: from config
28+
on: this._config.on,
2729
jobs: Object.fromEntries(
2830
Object.entries(this._jobs).map(([name, job]) => [name, job.toJSON()]),
2931
),

0 commit comments

Comments
 (0)