[GH-ISSUE #185] local js action fails (uses: ./) #125

Closed
opened 2026-03-01 21:40:25 +03:00 by kerem · 4 comments
Owner

Originally created by @helaili on GitHub (Apr 3, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/185

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.

Originally created by @helaili on GitHub (Apr 3, 2020). Original GitHub issue: https://github.com/nektos/act/issues/185 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](https://help.github.com/en/actions/building-actions/creating-a-javascript-action#example-using-a-private-action) ```yaml 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](https://github.com/actions/hello-world-javascript-action.git), you just need to add a basic workflow.
kerem 2026-03-01 21:40:25 +03:00
Author
Owner

@rdlf0 commented on GitHub (May 10, 2020):

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.

<!-- gh-comment-id:626400133 --> @rdlf0 commented on GitHub (May 10, 2020): 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.
Author
Owner

@macdaddyaz commented on GitHub (Jun 23, 2020):

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.

<!-- gh-comment-id:648481055 --> @macdaddyaz commented on GitHub (Jun 23, 2020): 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.... ```yaml - name: Auth0 deployment uses: ./.github/actions/auth0-deploy ``` And my action.yml file in that directory looks like this: ```yaml 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`.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 23, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:678712699 --> @github-actions[bot] commented on GitHub (Aug 23, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@JerkyTreats commented on GitHub (Sep 14, 2020):

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

<!-- gh-comment-id:692339393 --> @JerkyTreats commented on GitHub (Sep 14, 2020): Can this be reopened? I've confirmed this use case breaks for me: ```yaml - 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`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#125
No description provided.