Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean input does not meet YAML 1.2 "Core Schema" #287

Open
pantelis-karamolegkos opened this issue Sep 18, 2022 · 3 comments
Open

Boolean input does not meet YAML 1.2 "Core Schema" #287

pantelis-karamolegkos opened this issue Sep 18, 2022 · 3 comments
Labels
question A question on how to use this action

Comments

@pantelis-karamolegkos
Copy link

pantelis-karamolegkos commented Sep 18, 2022

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
@pantelis-karamolegkos pantelis-karamolegkos changed the title Undefined input when retrieved from the core package Boolean input not matching YAML schema Sep 19, 2022
@pantelis-karamolegkos pantelis-karamolegkos changed the title Boolean input not matching YAML schema Boolean input not meet YAML schema Sep 19, 2022
@pantelis-karamolegkos pantelis-karamolegkos changed the title Boolean input not meet YAML schema Boolean input not meet YAML 1.2 "Core Schema" Sep 19, 2022
@pantelis-karamolegkos pantelis-karamolegkos changed the title Boolean input not meet YAML 1.2 "Core Schema" Boolean input does not meet YAML 1.2 "Core Schema" Sep 19, 2022
@ismailhammounou
Copy link

Same for me

@ismailhammounou
Copy link

Any news ?

@joshmgross joshmgross added the question A question on how to use this action label Oct 13, 2022
@joshmgross
Copy link
Member

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}))

v1v added a commit to elastic/apm-pipeline-library that referenced this issue Nov 7, 2023
v1v added a commit to v1v/apm-pipeline-library that referenced this issue Nov 7, 2023
see actions/github-script#287

chore: change variable names
v1v added a commit to elastic/apm-pipeline-library that referenced this issue Nov 7, 2023
see actions/github-script#287

chore: change variable names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question on how to use this action
Projects
None yet
Development

No branches or pull requests

3 participants