[core] getInput returns empty string
Describe the bug
core.getInput("username") returns an empty string while username is required and has been set.
To Reproduce Steps to reproduce the behavior:
- Create a JavaScript action with
usernameas required input (also actually give the input in a workflow) - Access the
usernameinput anywhere in the code withconst core = require("@actions/core");andcore.getInput("username"); - It returns an empty string
Expected behavior
core.getInput("username") to return the value I've given in a workflow, which in my case is AceKiron
Workflow runner (please complete the following information):
- OS: Ubuntu
- Version Latest
Nevermind, am just dumb.
could you give the solution Im facing same problem
Unfortunately I don't remember the solution, perhaps it was some misspelling?
I wish it was a misspelling
I even tried with required flag.... always returning empty core.getInput('procedure', { required: true })
Interesting, could you show me your action.yml file?
I'm running into the same thing, core.getInput('value') returns empty string, while ${{ inputs.value }} correctly gives me the input value of my action. :shrug:
I keep getting this error when I use github-script. I figured it could be that getInput refers to the inputs the actions/github-script gets and not the inputs of the workflow where I use it. Quite misleading in this context, because we can't set inputs to this predefined action ourselves and reading the inputs defined for this action doesn't make sense for most users. Then again, the JS library was created mainly for writing custom actions and github-script is just a shorthand.
I only wish that this method would throw an error by default instead of pretending that an empty string is fine.
It looks like @pawkubik is right. core.getInput refers to the inputs of the step, not of the workflow. The following returned "warning: unexpected input" but worked. name: DEBUG Execute checks and update PRs
on:
workflow_dispatch:
inputs:
branch:
type: string
default: 'dev'
jobs:
update_prs:
runs-on: ubuntu-latest
steps:
...
- name: Set check runs on submodule PRs
uses: actions/github-script@v7
with:
branch: ${{ inputs.branch }}
script: |
const branchToMatch = core.getInput('branch');