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

FAQ: how to use this action with ACT #19

Open
Erriez opened this issue Aug 16, 2021 · 10 comments
Open

FAQ: how to use this action with ACT #19

Erriez opened this issue Aug 16, 2021 · 10 comments
Labels

Comments

@Erriez
Copy link

Erriez commented Aug 16, 2021

name: CI
on:
  push:
    branches:
      - master

jobs:
  build:
    name: Build image
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - uses: kohlerdominik/docker-run-action@v1
        with:
          image: alpine:latest
          run: |
            echo "hello world"
            uname -a

Running with act displays:

...
[CI/Build image] ⭐  Run kohlerdominik/docker-run-action@v1
INFO[0000]   ☁  git clone 'https://github.com/kohlerdominik/docker-run-action' # ref=v1 
[CI/Build image]   🐳  docker cp src=/home/a/.cache/act/kohlerdominik-docker-run-action@v1/ dst=/var/run/act/actions/kohlerdominik-docker-run-action@v1/
[CI/Build image]   🐳  docker exec cmd=[mkdir -p /var/run/act/actions/kohlerdominik-docker-run-action@v1/] user=
[CI/Build image]   🐳  docker exec cmd=[node /var/run/act/actions/kohlerdominik-docker-run-action@v1/dist/index.js] user=
[CI/Build image]   ❗  ::error::ENOENT: no such file or directory, open '/home/runner/work/_temp/759878e4-631e-4f34-bc43-89dcd12e2365.sh'
[CI/Build image]   ❌  Failure - kohlerdominik/docker-run-action@v1
Error: exit with `FAILURE`: 1

Any idea?

@kohlerdominik
Copy link
Owner

Looks like for some reason the run-command didn't get copied in the file. Let me investigate.

@kohlerdominik
Copy link
Owner

@Erriez I think the issue is, that act runs in a container. Therefore it should mount a file from one container to another, which most likely doesn't work. The command failing is something like:
docker run --volume /home/runner/work/_temp/759878e4-631e-4f34-bc43-89dcd12e2365.sh:/tmp/759878e4-631e-4f34-bc43-89dcd12e2365.sh [more options]

Docker now tries to access the file /home/runner/work/_temp/759878e4-631e-4f34-bc43-89dcd12e2365.sh on the host, but the file exists only in the action container.

Maybe @catthehacker can confirm this and has an idea how it would work with ACT?

@Erriez
Copy link
Author

Erriez commented Aug 16, 2021

@kohlerdominik Thanks for your fast reply. I think you're right: I've created a test case in branch docker-run-action:
https://github.com/Erriez/act-testcase/blob/docker-run-action/.github/workflows/CI.yml
And the Github Action was successful: https://github.com/Erriez/act-testcase/actions/runs/1136905928 and won't run with act.

@kohlerdominik
Copy link
Owner

If you're interessted in contributing a solution, you could investigate whether act supports a shared directory between action container and host.

If it does, we can adjust dockerRun.ts::8 to allow a variable, which then can point to that directory.

@catthehacker
Copy link

You should not hardcode paths to /home/runner

@catthehacker
Copy link

...
[CI/Build image] ⭐  Run kohlerdominik/docker-run-action@v1
INFO[0000]   ☁  git clone 'https://github.com/kohlerdominik/docker-run-action' # ref=v1 
[CI/Build image]   🐳  docker cp src=/home/a/.cache/act/kohlerdominik-docker-run-action@v1/ dst=/var/run/act/actions/kohlerdominik-docker-run-action@v1/
[CI/Build image]   🐳  docker exec cmd=[mkdir -p /var/run/act/actions/kohlerdominik-docker-run-action@v1/] user=
[CI/Build image]   🐳  docker exec cmd=[node /var/run/act/actions/kohlerdominik-docker-run-action@v1/dist/index.js] user=
[CI/Build image]   ❗  ::error::ENOENT: no such file or directory, open '/home/runner/work/_temp/759878e4-631e-4f34-bc43-89dcd12e2365.sh'
[CI/Build image]   ❌  Failure - kohlerdominik/docker-run-action@v1
Error: exit with `FAILURE`: 1

It doesn't work probably because you are using container with root user while the action expects runner due to hardcoded paths.

@kohlerdominik
Copy link
Owner

Thanks @catthehacker! I can try to resolve the home dir from the environment variable.

@catthehacker
Copy link

catthehacker commented Aug 16, 2021

You can use ghcr.io/catthehacker/ubuntu:runner-latest or ghcr.io/catthehacker/ubuntu:full-latest to have runner user
First image is based on ghcr.io/catthehacker/ubuntu:act-latest but uses runner user, 2nd image is built from GitHub Action runner template and is about 40GB in size.
After that you would need to chmod/chown the docker socket

bad perms /var/run/docker.sock

image

fix

image

@kohlerdominik
Copy link
Owner

I published a release which now imports the TEMP-path from the given environment variable.

However, as I understood, this was not the root cause for this issue; in the unix runner it should've worked either way.
@Erriez could you make it work with the instructions from @catthehacker ? As I understood, the only change you have to make is to run this before the actual action:

- run: sudo chmod 0777 /var/run/docker.sock

@kohlerdominik kohlerdominik self-assigned this Sep 7, 2021
@Erriez
Copy link
Author

Erriez commented Sep 8, 2021

@kohlerdominik Now I understand the change:

name: CI
on:
  push:
    branches:
      - master

jobs:
  build:
    name: Build image
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - run: sudo chmod 0777 /var/run/docker.sock

      - uses: kohlerdominik/docker-run-action@v1
        with:
          image: alpine:latest
          run: |
            echo "hello world"
            uname -a
$ act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:runner-latest

[CI/Build image] 🚀  Start image=ghcr.io/catthehacker/ubuntu:runner-latest
[CI/Build image]   🐳  docker run image=ghcr.io/catthehacker/ubuntu:runner-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[CI/Build image]   🐳  docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root
[CI/Build image]   🐳  docker cp src=/home/erwin/src/kohlerdominik_docker-run-action_issues_19/. dst=/home/erwin/src/kohlerdominik_docker-run-action_issues_19
[CI/Build image]   🐳  docker exec cmd=[mkdir -p /home/erwin/src/kohlerdominik_docker-run-action_issues_19] user=
[CI/Build image] ⭐  Run Checkout
[CI/Build image]   ✅  Success - Checkout
[CI/Build image] ⭐  Run sudo chmod 0777 /var/run/docker.sock
[CI/Build image]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /home/erwin/src/kohlerdominik_docker-run-action_issues_19/workflow/1] user=
[CI/Build image]   ✅  Success - sudo chmod 0777 /var/run/docker.sock
[CI/Build image] ⭐  Run kohlerdominik/docker-run-action@v1
INFO[0000]   ☁  git clone 'https://github.com/kohlerdominik/docker-run-action' # ref=v1 
[CI/Build image]   🐳  docker cp src=/home/erwin/.cache/act/kohlerdominik-docker-run-action@v1/ dst=/var/run/act/actions/kohlerdominik-docker-run-action@v1/
[CI/Build image]   🐳  docker exec cmd=[mkdir -p /var/run/act/actions/kohlerdominik-docker-run-action@v1/] user=
[CI/Build image]   🐳  docker exec cmd=[node /var/run/act/actions/kohlerdominik-docker-run-action@v1/dist/index.js] user=
| 
| These instructions are passed to the container:
| ----- START OF FILE -----
| echo "hello world"
| uname -a
| ----- END OF FILE -----
| [command]/usr/bin/docker run --volume=/home/runner/work/_temp/efa60418-7a39-4f28-9c5f-01aee88f6bac.sh:/tmp/efa60418-7a39-4f28-9c5f-01aee88f6bac.sh alpine:latest sh -e /tmp/efa60418-7a39-4f28-9c5f-01aee88f6bac.sh
[CI/Build image]   ✅  Success - kohlerdominik/docker-run-action@v1

Option -P is also required, because the same error occurs with act command only. This explained the issue.

Thanks!

@kohlerdominik kohlerdominik changed the title ::error::ENOENT: no such file or directory FAQ: how to use this action with ACT Sep 13, 2021
@kohlerdominik kohlerdominik removed their assignment May 17, 2024
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

3 participants