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

problem executing actions in versions over 1.5.1 #102

Closed
SilverZerOne opened this issue Sep 5, 2024 · 4 comments
Closed

problem executing actions in versions over 1.5.1 #102

SilverZerOne opened this issue Sep 5, 2024 · 4 comments
Assignees

Comments

@SilverZerOne
Copy link

node version 18 or 20
typescript version 4.9.5
@github/local-action >2.0.0

When I try to execute an action un version >=2.0.0

for example local-action run .github\actions\validate-sgon ../../../src/main/actions/validateSgonAction.ts .env

node:fs:453
return binding.readFileUtf8(path, stringToFlags(options.flag));
^

Error: ENOENT: no such file or directory, open 'C:\Users\x648580\NodeProjects\gln-api-orchestator-manager-action.github\actions\validate-sgon\package.json'
at Object.readFileSync (node:fs:453:20)
at isESM (c:\Users\x648580\AppData\Roaming\npm\node_modules@github\local-action\src\utils\package.ts:11:8)
at action (c:\Users\x648580\AppData\Roaming\npm\node_modules@github\local-action\src\commands\run.ts:95:7)
at Command. (c:\Users\x648580\AppData\Roaming\npm\node_modules@github\local-action\src\command.ts:112:7) {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\Users\x648580\NodeProjects\gln-api-orchestator-manager-action\.github\actions\validate-sgon\package.json'
}

BUT when i downgrade to @github/local-action 1.5.1 Its WORK!

My code was compiled with ncc :
"build:sgon": "ncc build --source-map -o .github/actions/validate-sgon src/main/actions/validateSgonAction.ts",

if you need more evidence, im really happy to help us!

@ncalteen
Copy link
Collaborator

ncalteen commented Sep 5, 2024

Heyo, thanks for the detailed info! I am checking into this a bit now. Do you by chance have a public repo that can be used to reproduce this error?

@ncalteen
Copy link
Collaborator

ncalteen commented Sep 5, 2024

I think I found part of the problem. It's based on the structure of the action repository. Originally I built this tool to support the structure in the TypeScript and JavaScript action templates. They both look like the following:

.
├── action.yml
├── src
│   ├── index.ts
│   └── main.ts
└── tsconfig.json

However it looks like your repo looks more like this...

.
├── .github
│   └── actions
│       └── validate-sgon
│           └── action.yml
└── src
    └── main
        └── actions
            └── validateSgonAction.ts

When local-action runs, it starts by looking for the full path to the action. In your case, something like this: C:\Users\x648580\NodeProjects\gln-api-orchestator-manager-action\.github\actions\validate-sgon.

Next, it looks for the package.json for the source of the action code. Currently, it expects that to be in the same directory as the action.yml (not your issue or anything, I simply didn't take this repo structure into account).

I should be able to set this up to instead traverse the directory structure from the entrypoint (validateSgonAction.ts) upwards until it finds the package.json :)

ncalteen added a commit that referenced this issue Sep 5, 2024
Ref #102 

Depending on the structure of the action repository, the `node_modules`
and `package.json` needed by `local-action` may not exist in the
expected locations. This PR updates the behavior of the action to
instead walk the directory structure and attempt to locate the paths
more dynamically, allowing support for more customized action
repositories.
@ncalteen
Copy link
Collaborator

ncalteen commented Sep 5, 2024

Just published version 2.1.2 of this tool :) Can you give that a try?

@ncalteen ncalteen self-assigned this Sep 5, 2024
@SilverZerOne
Copy link
Author

SilverZerOne commented Sep 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants