Skip to content

Commit

Permalink
move to a file based function input
Browse files Browse the repository at this point in the history
  • Loading branch information
gjedlicska committed Aug 10, 2023
1 parent c3d711f commit 3523652
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ inputs:
speckle_function_id:
description: 'The unique identifier of the function. Go to automate to generate one.'
required: true
speckle_function_input_schema:
description: 'JSON Schema of the parameters object required by the function.'
speckle_function_input_schema_file_path:
description: 'File path containing JSON Schema of the parameters object required by the function.'
required: false
speckle_function_command:
description: 'The command to run to execute the function in a runtime environment.'
Expand Down
2 changes: 1 addition & 1 deletion dist/action/37.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 20 additions & 8 deletions dist/action/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/action/index.js.map

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core'
import { z } from 'zod'
import fetch from 'node-fetch'
import { retry } from '@lifeomic/attempt'
import { readFileSync } from 'node:fs'

const InputVariablesSchema = z.object({
speckleAutomateUrl: z.string().url().nonempty(),
Expand All @@ -19,8 +20,11 @@ const parseInputs = (): InputVariables => {

let speckleFunctionInputSchema: Record<string, unknown> | null = null
try {
const rawInputSchema = core.getInput('speckle_function_input_schema')
if (rawInputSchema) speckleFunctionInputSchema = JSON.parse(rawInputSchema)
const rawInputSchemaPath = core.getInput('speckle_function_input_schema_file_path')
if (rawInputSchemaPath) {
const rawInputSchema = readFileSync(rawInputSchemaPath, 'utf-8')
speckleFunctionInputSchema = JSON.parse(rawInputSchema)
}
} catch (err) {
core.setFailed(`Parsing the function input schema failed with: ${err}`)
throw err
Expand Down

0 comments on commit 3523652

Please sign in to comment.