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

${{ github.action_path }} makes no sense when action is run inside self-hosted custom container. #716

Closed
sebastian-freitag opened this issue Sep 22, 2020 · 16 comments · Fixed by #1762 or morph027/apt-repo-action#7
Assignees
Labels
bug Something isn't working Runner Bug Bug fix scope to the runner

Comments

@sebastian-freitag
Copy link

Describe the bug
${{ github.action_path }} points to a location in the host filesystem of the github runner host. Not to /__w/_actions/...

To Reproduce
Steps to reproduce the behavior:

  1. Create a custom container.
  2. Create a workflow that uses the custom docker container on a self-hosted runner.
  3. Try to follow the guide for the new composite actions that requires to use ${{ github.action_path }}, for example to locate a shell script of a composite action.

Expected behavior
The shell script is found and executed, just like when doing this with a normal ubuntu-latest runner.

Runner Version and Platform

v2.273.4 on Linux.

OS of the machine running the runner? OSX/Windows/Linux/...
Linux.

What's not working?

(...)
##[error]Process completed with exit code 127.
Run pylot-tech/actions_checkout@v1
/__w/_temp/615e5631-1155-478e-93e8-8e5cc51fb88e.sh: line 1: /home/github-runner/actions-runner-new/_work/_actions/pylot-tech/actions_checkout/v1/clone.sh: No such file or directory
@AltiusRupert
Copy link

Hi Sebastian,,
SImilar issue here.
Did you figure out a way of running your script ?

@AltiusRupert
Copy link

See also #649

@sebastian-freitag
Copy link
Author

sebastian-freitag commented Oct 19, 2020

Hi Sebastian,,
SImilar issue here.
Did you figure out a way of running your script ?

By not using ${{ github.action_path }} and instead hard-coding the location:

runs:
  using: "composite"
  steps:
    - run: /__w/_actions/(... repo of my script ...)/v1/clone.sh
      shell: bash

Ugly, quick solution.

@AltiusRupert
Copy link

Hi Sebastian,
Thanks for your answer.

I too found this same workaround in the meantime.

duament added a commit to duament/build-arch-package that referenced this issue Feb 3, 2021
@zotrix
Copy link

zotrix commented Mar 10, 2021

seems like env variable GITHUB_ACTION_PATH set to correct path.
so step could be called via GITHUB_ACTION_PATH instead of ${{ github.action_path }}

  - run: ${GITHUB_ACTION_PATH}/setup.sh
    shell: sh

@travislikestocode
Copy link

travislikestocode commented May 26, 2021

Here's a workaround that will allow you to use existing composite actions without modifying them. This should work on self-hosted runners using a BASH shell with gnu utils. Note that this includes a workaround for #691 as well with the step ID get-user. The one for this bug is the workdir step. I'm including it in case someone finds this bug first.

jobs:
  docker_workaround:
    runs-on: [ your-tags ]
    outputs:
      uid_gid: ${{ steps.get-user.outputs.uid_gid }}
      workdir: ${{ steps.get-workdir.outputs.workdir }}
    steps:
      - id: get-user
        run: echo "::set-output name=uid_gid::$(id -u):$(id -g)"

      - id: get-workdir
        run: echo "::set-output name=workdir::$(echo '${{ runner.workspace }}' | sed s:/[^/]*$::)"

Then on the job which uses a composite action:

  the-job:
    name: I am a job
    needs:
      - docker_workaround
    runs-on: [ your-tags ]
    container:
      image: your-image
      options: --user ${{ needs.docker_workaround.outputs.uid_gid }}
      volumes:
        - ${{ needs.docker_workaround.outputs.workdir }}:${{ needs.docker_workaround.outputs.workdir }}
...

@FearlessHyena
Copy link

Any chance of getting ${{ github.action_path }} to point to the correct location without the workaround?

@nikola-jokic
Copy link
Contributor

Hey everyone,

We created a PR fixing this issue 😊.

@ricardo-noyolalozano
Copy link

4 years later and this is still broken

pguyot added a commit to pguyot/arm-runner-action that referenced this issue Apr 29, 2024
pguyot added a commit to pguyot/arm-runner-action that referenced this issue May 5, 2024
@ElvenSpellmaker
Copy link

Hey everyone,

We created a PR fixing this issue 😊.

Any update on this please? It's still an issue now (definitely for GHES at least).

@joaoantoniocardoso
Copy link

I hope this can be fixed soon

@zachspar
Copy link

zachspar commented Jun 6, 2024

We created a PR fixing this issue 😊.

@nikola-jokic not sure why this is closed... still a problem!

akladiev added a commit to akladiev/openvino that referenced this issue Jul 23, 2024
akladiev added a commit to akladiev/openvino that referenced this issue Jul 23, 2024
fionn added a commit to fionn/newline-linter that referenced this issue Aug 16, 2024
There is a runner bug where the github.action_path and
GITHUB_ACTION_PATH variables are not equal when running in a container
on a self-hosted runner, with the former being set incorrectly. See
actions/runner#716 for details.

Fixes #1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Runner Bug Bug fix scope to the runner
Projects
None yet