Boolean input does not meet YAML 1.2 "Core Schema"
I have a reusable workflow (i.e. triggered by the workflow_call event)
I also have the following input defined in it:
do_something:
description: whether to do something
required: true
type: boolean
default: false
I use the github actions script to invoke a script from a separate file as instructed here, passing the core package as input
- name: checkout the project
uses: actions/checkout@v2
- uses: actions/github-script@v6
id: set-images
with:
script: |
const script = require('./.github/workflows/myscript.js')
console.log(script({core}))
Here is myscript.js
module.exports = ({core}) => {
console.log(core.getBooleanInput['do_something'])
return 0
}
This comes from the documentation of core package found here.
However this attempt fails:
TypeError: Input does not meet YAML 1.2 "Core Schema" specification: do_something
Support boolean input list: `true | True | TRUE | false | False | FALSE`
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS:
ubuntu-latest - Browser: chrome
- Version:
v6
Same for me
Any news ?
core.getInput is for action inputs, it doesn't read workflow inputs. I suspect this error is occurring due to the do_something input being undefined.
You could workaround this in a few ways:
Use an environment variable
- uses: actions/github-script@v6
id: set-images
env:
DO_SOMETHING: ${{ inputs.do_something }}
with:
script: |
const script = require('./.github/workflows/myscript.js')
console.log(script({core}))
And then read that value in your script:
console.log(JSON.parse(process.env.DO_SOMETHING.toLowerCase()))
The JSON.parse should give you a boolean, but it would have unexpected results for non-boolean values.
Use an input variable
Warning This may add a warning that the input isn't part of
actions/github-script
- uses: actions/github-script@v6
id: set-images
with:
do_something: ${{ inputs.do_something }}
script: |
const script = require('./.github/workflows/myscript.js')
console.log(script({core}))
The script should work as-is.
Use an environment variable and match the format of input
Action inputs are just input variables in a special format https://github.com/actions/toolkit/blob/ffb7e3e14ed5e28ae00e9c49ba02b2764d57a6b7/packages/core/src/core.ts#L127-L128
I think we could use an env variable and fake it as an input. This would allow your script to remain unchanged but I don't know if it will get rid of the unrecognized input warnings.
- uses: actions/github-script@v6
id: set-images
env:
INPUT_DO_SOMETHING: ${{ inputs.do_something }}
with:
script: |
const script = require('./.github/workflows/myscript.js')
console.log(script({core}))