Skip to content

Commit 303912d

Browse files
authored
feat(run): Support if (#31)
1 parent 603f57f commit 303912d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/package/step.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ describe("stepJSON", () => {
3232
{ kind: "run", shell: "bash", command: "echo 'Hello, world!'" },
3333
{ shell: "bash", run: "echo 'Hello, world!'" },
3434
],
35+
[
36+
{ kind: "run", if: "always()", command: "echo 'Hello, world!'" },
37+
{ if: "always()", run: "echo 'Hello, world!'" },
38+
],
3539
])("stepJSON(%j) -> %j", (input, expected) => {
3640
expect(stepJSON(input)).toEqual(expected);
3741
});
@@ -63,6 +67,10 @@ describe("stepJSON", () => {
6367
{ kind: "uses", name: "test", action: "actions/checkout@v4" },
6468
{ name: "test", uses: "actions/checkout@v4" },
6569
],
70+
[
71+
{ kind: "uses", if: "always()", action: "actions/checkout@v4" },
72+
{ if: "always()", uses: "actions/checkout@v4" },
73+
],
6674
])("stepJSON(%j) -> %j", (input, expected) => {
6775
expect(stepJSON(input)).toEqual(expected);
6876
});

lib/package/step.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type StepBase = {
44
id?: string;
55
name?: string;
66
env?: Record<string, string>;
7-
// TODO: if
7+
if?: string | boolean | number;
88
// TODO: continue-on-error
99
// TODO: timeout-minutes
1010
};
@@ -29,6 +29,7 @@ export function stepJSON(step: Step): Record<string, unknown> {
2929
...(step.id != null && { id: step.id }),
3030
...(step.name != null && { name: step.name }),
3131
...(step.env != null && { env: step.env }),
32+
...(step.if != null && { if: step.if }),
3233
};
3334

3435
switch (step.kind) {

0 commit comments

Comments
 (0)