getInput not working anymore on nodejs
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Description
If i follow the steps to create a git hub action in node js (https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action) the getInput method returns an empty string. If i check all the created environment variables no 'INPUT_' variable is set. I would assume that some used dependency causing this error as it was working two weeks ago, but as i am not too deep into this library, you can probably find and fix this more easily.
To Reproduce
create action.yml
name: 'Hello World'
description: 'Greet someone and record the time'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'node20'
main: 'index.js'
create package.json
{
"name": "tmp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^5.1.1"
}
}
create index.js
const core = require('@actions/core');
const github = require('@actions/github');
try {
// `who-to-greet` input defined in action metadata file
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
} catch (error) {
core.setFailed(error.message);
}
run application
npm install
node ./index.js
Take a look at the output. You will see Hello ! instead of Hello World!
Expected behaviour
See the message Hello World! with the action property set.
Environment:
- OS: osx Ventura 13.6.1
- Node: v20.1.0
Also tested on another mac, which was also failing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported action.yml, package.json, and index.js reproduction, then run npm install and node ./index.js as described. Compare that local execution with the GitHub Actions example linked in the report and verify whether getInput receives the action input there. Done means establishing the expected behavior and either correcting it or documenting the required execution context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- ci-cd, devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100