From ca5bb3f10f8ce0965d4532ac6a3730ee2a8aa80d Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Wed, 10 Apr 2024 06:07:55 +0000 Subject: [PATCH] feat: allow multiline args --- .github/workflows/multiline.yml | 25 +++++++++++++++++++++++++ dist/action.js | 6 +++++- dist/setup.js | 25 +++++++++++++++++++++---- src/action.ts | 6 +++++- src/setup.ts | 26 ++++++++++++++++++++++---- 5 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/multiline.yml diff --git a/.github/workflows/multiline.yml b/.github/workflows/multiline.yml new file mode 100644 index 0000000..ad52085 --- /dev/null +++ b/.github/workflows/multiline.yml @@ -0,0 +1,25 @@ +name: Setup FluentCI With Args + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + setup-fluentci: + runs-on: ${{ matrix.os }} + continue-on-error: true + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v2 + - name: Setup FluentCI + uses: ./ + with: + wasm: true + pipeline: base_pipeline + args: | + hello Tsiry Sandratraina + hello again diff --git a/dist/action.js b/dist/action.js index d37185e..5184990 100644 --- a/dist/action.js +++ b/dist/action.js @@ -7,7 +7,11 @@ if (!process.env.RUNNER_TEMP) { setup({ daggerVersion: action.getInput("dagger-version"), wasm: action.getInput("wasm") === "false" ? false : action.getInput("wasm"), - args: action.getInput("args"), + args: action + .getInput("args") + .split("\n") + .map((arg) => arg.trim()) + .filter((arg) => arg), pipeline: action.getInput("pipeline"), }) .then(({ version }) => { diff --git a/dist/setup.js b/dist/setup.js index d5e48db..440ab66 100644 --- a/dist/setup.js +++ b/dist/setup.js @@ -33,17 +33,34 @@ export default async ({ daggerVersion, wasm, pipeline, args, }) => { const version = await verifyFluentCI("fluentci"); if (pipeline) { if (wasm) { - if (!args) { + if (!args.length) { throw new Error("args is required when using wasm"); } - await exec("fluentci", ["run", "--wasm", pipeline, ...args.split(" ")]); + for (const _args of args) { + await exec("fluentci", [ + "run", + "--wasm", + pipeline, + ..._args.split(" "), + ]); + } return { version }; } - if (!args) { + if (!args.length) { await exec("fluentci", ["run", pipeline]); return { version }; } - await exec("fluentci", ["run", pipeline, ...args.split(" ")]); + for (const _args of args) { + await exec("fluentci", ["run", pipeline, ..._args.split(" ")]); + } + } + if (!pipeline) { + if (args.length) { + for (const _args of args) { + await exec("fluentci", [..._args.split(" ")]); + } + return { version }; + } } return { version, diff --git a/src/action.ts b/src/action.ts index af923b9..4466934 100644 --- a/src/action.ts +++ b/src/action.ts @@ -9,7 +9,11 @@ if (!process.env.RUNNER_TEMP) { setup({ daggerVersion: action.getInput("dagger-version"), wasm: action.getInput("wasm") === "false" ? false : action.getInput("wasm"), - args: action.getInput("args"), + args: action + .getInput("args") + .split("\n") + .map((arg) => arg.trim()) + .filter((arg) => arg), pipeline: action.getInput("pipeline"), }) .then(({ version }) => { diff --git a/src/setup.ts b/src/setup.ts index af8fe6d..7be838d 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -48,17 +48,35 @@ export default async ({ if (pipeline) { if (wasm) { - if (!args) { + if (!args.length) { throw new Error("args is required when using wasm"); } - await exec("fluentci", ["run", "--wasm", pipeline, ...args.split(" ")]); + for (const _args of args) { + await exec("fluentci", [ + "run", + "--wasm", + pipeline, + ..._args.split(" "), + ]); + } return { version }; } - if (!args) { + if (!args.length) { await exec("fluentci", ["run", pipeline]); return { version }; } - await exec("fluentci", ["run", pipeline, ...args.split(" ")]); + for (const _args of args) { + await exec("fluentci", ["run", pipeline, ..._args.split(" ")]); + } + } + + if (!pipeline) { + if (args.length) { + for (const _args of args) { + await exec("fluentci", [..._args.split(" ")]); + } + return { version }; + } } return {