I have been trying to get the following tutorial working for building custom github actions
My package.json looks like this:
{
"name": "read-deploy-instructions",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "ncc build index.js -o /dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.9.0",
"@actions/github": "^5.0.3"
},
"devDependencies": {
"@vercel/ncc": "latest"
}
}
My index.js looks like this:
import core from '@actions/core';
import github from '@actions/github';
try {
// `who-to-greet` input defined in action metadata file
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
const time = (new Date()).toTimeString();
core.setOutput("time", time);
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`);
} catch (error) {
core.setFailed(error.message);
}
If I run the command:
npm run build
I get the error shown above. I have seen multiple people posting it doesn't work with similar errors but no resolution. Does anyone have any ideas?
Thanks in advance,
CodePudding user response:
OK after many a wasted hour I realized the file I was trying to target was named incorrectly. I was telling the NCC commands to look for "index.js" but had mistakenly named it "index,js". After renaming the file the NCC commands worked successfully and as expected.