Skip to content

JavaScript (node-script@v1)

Run a small JavaScript transform or glue step with action-owned Node.js.

Contributions are welcome. The repository is public, so improvements, bug reports, and pull requests can go to dagucloud/node-script.

Example

yaml
steps:
  - id: compute
    action: node-script@v1
    with:
      input:
        version: "1.2.3"
        services: ["api", "worker"]
      script: |
        console.log("preparing release", input.version)

        return {
          tag: `v${input.version}`,
          serviceCount: input.services.length
        }

  - id: print
    run: echo "release tag is ${compute.outputs.result.tag}"
    depends: compute

script is a JavaScript async function body. return publishes result. The action exposes input, params, env, and a captured console object.

Outputs

FieldDescription
oktrue when the script completed successfully.
resultJSON-compatible value returned by the script.
stdoutText written through console.log, console.info, console.debug, or console.dir.
stderrText written through console.warn or console.error.
durationMsWrapper-measured script duration in milliseconds.
nodeVersionNode.js version used by the action.
errorError object when the script fails.

Released under the MIT License.