diff --git a/action.yml b/action.yml index 56cda02..55c8a76 100644 --- a/action.yml +++ b/action.yml @@ -18,6 +18,9 @@ inputs: description: Dagger version to install required: false default: 0.11.0 + working-directory: + description: Set the current working directory + default: . outputs: version: description: FluentCI CLI version installed diff --git a/dist/action.js b/dist/action.js index 5184990..5b36aab 100644 --- a/dist/action.js +++ b/dist/action.js @@ -13,6 +13,7 @@ setup({ .map((arg) => arg.trim()) .filter((arg) => arg), pipeline: action.getInput("pipeline"), + workdir: action.getInput("working-directory"), }) .then(({ version }) => { action.setOutput("version", version); diff --git a/dist/setup.js b/dist/setup.js index 73191ad..dd85ce8 100644 --- a/dist/setup.js +++ b/dist/setup.js @@ -3,7 +3,7 @@ import { join } from "node:path"; import * as action from "@actions/core"; import { getExecOutput, exec } from "@actions/exec"; import { installDocker } from "./setup-docker.js"; -export default async ({ daggerVersion, wasm, pipeline, args, }) => { +export default async ({ daggerVersion, wasm, pipeline, args, workdir, }) => { // throw error on unsupported platforms (windows) if (process.platform === "win32") { throw new Error("FluentCI is not supported on Windows"); @@ -37,31 +37,34 @@ export default async ({ daggerVersion, wasm, pipeline, args, }) => { throw new Error("args is required when using wasm"); } for (const _args of args) { - await exec("fluentci", [ - "run", - "--wasm", - pipeline, - ..._args.split(" "), - ]); + await exec("fluentci", ["run", "--wasm", pipeline, ..._args.split(" ")], { + cwd: workdir, + }); } return { version }; } if (!args.length) { - await exec("fluentci", ["run", pipeline]); + await exec("fluentci", ["run", pipeline], { cwd: workdir }); return { version }; } for (const _args of args) { - await exec("fluentci", ["run", pipeline, ..._args.split(" ")]); + await exec("fluentci", ["run", pipeline, ..._args.split(" ")], { + cwd: workdir, + }); } } if (!pipeline) { if (args.length) { for (const _args of args) { if (wasm) { - await exec("fluentci", ["run", "--wasm", ..._args.split(" ")]); + await exec("fluentci", ["run", "--wasm", ..._args.split(" ")], { + cwd: workdir, + }); } else { - await exec("fluentci", ["run", ..._args.split(" ")]); + await exec("fluentci", ["run", ..._args.split(" ")], { + cwd: workdir, + }); } } return { version }; diff --git a/src/action.ts b/src/action.ts index 4466934..f400f86 100644 --- a/src/action.ts +++ b/src/action.ts @@ -15,6 +15,7 @@ setup({ .map((arg) => arg.trim()) .filter((arg) => arg), pipeline: action.getInput("pipeline"), + workdir: action.getInput("working-directory"), }) .then(({ version }) => { action.setOutput("version", version); diff --git a/src/setup.ts b/src/setup.ts index 9c8e916..dcafbf3 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -9,6 +9,7 @@ export default async ({ wasm, pipeline, args, + workdir, }): Promise<{ version: string; }> => { @@ -52,21 +53,24 @@ export default async ({ throw new Error("args is required when using wasm"); } for (const _args of args) { - await exec("fluentci", [ - "run", - "--wasm", - pipeline, - ..._args.split(" "), - ]); + await exec( + "fluentci", + ["run", "--wasm", pipeline, ..._args.split(" ")], + { + cwd: workdir, + } + ); } return { version }; } if (!args.length) { - await exec("fluentci", ["run", pipeline]); + await exec("fluentci", ["run", pipeline], { cwd: workdir }); return { version }; } for (const _args of args) { - await exec("fluentci", ["run", pipeline, ..._args.split(" ")]); + await exec("fluentci", ["run", pipeline, ..._args.split(" ")], { + cwd: workdir, + }); } } @@ -74,9 +78,13 @@ export default async ({ if (args.length) { for (const _args of args) { if (wasm) { - await exec("fluentci", ["run", "--wasm", ..._args.split(" ")]); + await exec("fluentci", ["run", "--wasm", ..._args.split(" ")], { + cwd: workdir, + }); } else { - await exec("fluentci", ["run", ..._args.split(" ")]); + await exec("fluentci", ["run", ..._args.split(" ")], { + cwd: workdir, + }); } } return { version };