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

Cannot find local action #307

Closed
aeisenberg opened this issue Jul 17, 2020 · 8 comments
Closed

Cannot find local action #307

aeisenberg opened this issue Jul 17, 2020 · 8 comments
Labels

Comments

@aeisenberg
Copy link

I have a job that looks like this:

name: "Integration Testing"

on: [push, pull_request]

jobs:

  mock-job:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Move action
      shell: bash
      run: |
        mkdir ../action
        mv * .github ../action/
        mv ../action/tests/multi-language-repo/{*,.github} .
    - uses: ./../action/init

When I run this on CI, there are no problems. But, when I run this through act -j mock-job I get this error:

[Integration Testing/testing-job]   ❌  Failure - ./../action/init
Error: open /Users/andrew.eisenberg/repos/action/init/action.yaml: no such file or directory

Note that the init/action.yml file exists at /Users/andrew.eisenberg/repos/my-repo/init/action.yaml.

It looks like github is running the entire job inside of the docker container, whereas act is running some parts outside of it. Notably, it is looking for the action files on the host filesystem and the rest seems to be in the docker container.

@aeisenberg
Copy link
Author

aeisenberg commented Jul 19, 2020

My guess is that this line is incorrect:

actionDir := filepath.Join(rc.Config.Workdir, step.Uses)

It is using the local filesystem path to get to the action. But, I think it should be the path inside of the docker image.

@benwinding
Copy link

Seems to work if you set the reference to the local action from the root of the git folder

Github workflow

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - name: Run test action
      uses: ./my-actions/action1

Local action

├── /.github
│    └── workflows
└── /my-actions
     └── /action1
         ├── action.yaml
         └── Dockerfile

@aeisenberg
Copy link
Author

Thanks for your response, though if I do what you are suggesting, then I'm pretty sure that the workflow would fail when I run it on CI.

@github-actions
Copy link
Contributor

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

@addisonklinke
Copy link

Still having trouble with this on act version 0.2.30. My repository has this structure

~/git/repository$ tree .github/
.github/
├── actions
│   └── setup-env.yaml
└── workflows
    └── pull_request_ci.yaml

Then within .github/workflows/pull_request_ci.yaml I try to use the action

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: ./.github/actions/setup-env.yaml

But triggering with act I still get

Failure - Main ./.github/actions/setup-env.yaml

I've tried both with and without the .yaml extension

@KnisterPeter
Copy link
Member

You need to checkout your repository to use local actions.

@ChristopherHX
Copy link
Contributor

ChristopherHX commented Aug 15, 2022

Still having trouble with this on act version 0.2.30. My repository has this structure

~/git/repository$ tree .github/
.github/
├── actions
│   └── setup-env.yaml
└── workflows
    └── pull_request_ci.yaml

Then within .github/workflows/pull_request_ci.yaml I try to use the action

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: ./.github/actions/setup-env.yaml

But triggering with act I still get

Failure - Main ./.github/actions/setup-env.yaml

I've tried both with and without the .yaml extension

Both your repository structure and uses syntax are wrong, this wouldn't work on github.

You have to change it to

~/git/repository$ tree .github/
.github/
├── actions
│   └── setup-env
│        └── action.yaml
└── workflows
    └── pull_request_ci.yaml
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ./.github/actions/setup-env

EDIT you can also use both action.yaml and action.yml

@addisonklinke
Copy link

@KnisterPeter @ChristopherHX thanks for the tips! After adding actions/checkout and restructuring the local setup-env/action.yaml, it is working

PetoMPP added a commit to PetoMPP/full-stack-todo-rust-course that referenced this issue Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants