When developing a new JS action, I like to create a workflow within the same repo so I can test various use cases. In such a case, I reference the local action with - uses: ./ as defined in the documentation
on: [push]
jobs:
hello_world_job:
runs-on: ubuntu-latest
name: A job to say hello
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: ./
with:
who-to-greet: 'Mona the Octocat'
Unfortunately, it fails with the following error:
internal/modules/cjs/loader.js:628
| throw err;
| ^
|
| Error: Cannot find module '/github/workspace/aws-instance-ripper/index.js'
| at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
| at Function.Module._load (internal/modules/cjs/loader.js:527:27)
| at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
| at internal/main/run_main_module.js:17:11 {
| code: 'MODULE_NOT_FOUND',
| requireStack: []
| }
It does work if I move the action code in an action subfolder and use it with - uses: ./action.
This can be reproduced with the sample hello-world-javascript-action, you just need to add a basic workflow.
Hey, I had the same issue, but already posted my solution in #228. You need to provide the path parameter to the actions/checkout action in order to get the correct path when the code is copied to the container.
Sorry if this belongs in a new issue, but I'm experiencing a very similar problem in a similar situation. I'll be glad to open a new issue, if that would be better....
It looks like act is not resolving relative paths within local actions the same way that GitHub Actions does.
For instance, I have a workflow referencing a local action....
- name: Auth0 deployment
uses: ./.github/actions/auth0-deploy
And my action.yml file in that directory looks like this:
name: auth0-deploy
inputs:
prod-branch:
description: Name of the branch to consider "production". Default is "master".
required: false
runs:
using: node12
main: 'dist/index.js'
When I run locally, I get the same kind of stack trace:
| internal/modules/cjs/loader.js:628
| throw err;
| ^
|
| Error: Cannot find module '/github/workspace/dist/index.js'
| at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
| at Function.Module._load (internal/modules/cjs/loader.js:527:27)
| at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
| at internal/main/run_main_module.js:17:11 {
| code: 'MODULE_NOT_FOUND',
| requireStack: []
| }
However, this configuration is valid per the GHA documentation, and the workflow runs successfully on GitHub. act should be resolving my action's main script to /github/workspace/.github/actions/auth0-deploy/dist/index.js, instead of just /github/workspace/dist/index.js.
Issue is stale and will be closed in 7 days unless there is new activity
Can this be reopened? I've confirmed this use case breaks for me:
- name: checkout foo
uses: actions/checkout@v2
path: .github/actions/foo
- name: use foo
uses: ./.github/actions/foo
Gets
Error: open /path/to/users/pwd/.github/actions/foo/action.yaml: no such file or directory
should resolve to
github/workspace/.github/actions/foo/action.yaml
Most helpful comment
Sorry if this belongs in a new issue, but I'm experiencing a very similar problem in a similar situation. I'll be glad to open a new issue, if that would be better....
It looks like
actis not resolving relative paths within local actions the same way that GitHub Actions does.For instance, I have a workflow referencing a local action....
And my action.yml file in that directory looks like this:
When I run locally, I get the same kind of stack trace:
However, this configuration is valid per the GHA documentation, and the workflow runs successfully on GitHub.
actshould be resolving my action's main script to/github/workspace/.github/actions/auth0-deploy/dist/index.js, instead of just/github/workspace/dist/index.js.