Skip to content

Commit

Permalink
feat: allow multiline args
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Apr 10, 2024
1 parent 11a7db8 commit ca5bb3f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 10 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/multiline.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
25 changes: 21 additions & 4 deletions dist/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
26 changes: 22 additions & 4 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ca5bb3f

Please sign in to comment.