question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

github.action_path contains wrong path when used inside a container

See original GitHub issue

Describe the bug When using ${{ github.action_path }} inside a local composite action and calling this action in a job that runs inside a container, ${{ github.action_path }} gets resolved to /home/runner/work/ga-test-public/ga-test-public/./.github/actions/repro instead of /__w/ga-test-public/ga-test-public/./.github/actions/repro.

There are other closed issues describing the same problem (https://github.com/actions/runner/issues/716, https://github.com/actions/runner/issues/965) and a merged pull request (https://github.com/actions/runner/pull/1762) that should have fixed the issue, but I am still getting the wrong path on GitHub shared runners with version 2.297.0

To Reproduce Here is a reproduction repo and a workflow run with the mentioned issue.

# .github/workflow/test.yml
name: Reploduce the bug

on: 
  push: {}
  workflow_dispatch: {}

jobs:
  bug-in-container:
    runs-on: ubuntu-20.04
    container:
      image: centos:7
    steps:
      - uses: actions/checkout@v2
      - uses: ./.github/actions/repro

      - run: echo runner.temp = ${{ runner.temp }}
      - run: ls -al ${{ runner.temp }} || true

      - run: echo runner.tool_cache = ${{ runner.tool_cache }}
      - run: ls -al ${{ runner.tool_cache }} || true
# .github/actions/repo/action.yml
name: 'Reproduce the bug'
description: ''
inputs: {}
runs:
  using: 'composite'
  steps:
    - shell: bash
      run: |
        echo github.action_path: ${{ github.action_path }}
        ls -al ${{ github.action_path }} || true

Expected behavior ${{ github.action_path }} should be resolved to a path inside the container, not to a path on the host machine.

Runner Version and Platform

GitHub shared runner version 2.297.0

What’s not working?

grafik

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nikola-jokiccommented, Oct 7, 2022

Hey @WIStudent,

Thank you for reporting this! We are aware of this issue. The PR #1762 solved this issue, but there was a problem with hash files, executing from a host machine. We are still exploring the best way to achieve this. I will post an update here about the progress regarding this issue.

0reactions
BitProcessorcommented, Aug 18, 2023

For anyone struggling with this:

Let’s say you created a custom action with a script, with the script called run.sh and residing in the root of the action.

runs:
  using: composite
  steps:
    - name: Run script
      shell: bash
      run: ${GITHUB_ACTION_PATH}/run.sh

That will get it to work if you are running your build inside a container.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect context paths in conteiner #965 - actions/runner
The context is filled wrong when a job runs inside container: ${{ runner.temp }}; ${{ runner.tool_cache }}; ${{ github.action_path }}.
Read more >
${{ github.action_path }} makes no sense when action is ...
The corresponding environment variable `GITHUB_ACTION_PATH` always contains valid path even actions running on self-hosted runners, so this PR ...
Read more >
Path to action in the same repository as workflow #26245
I have a repository with a rails app. The repository has its own action to run tests in a docker container. The workflow's...
Read more >
github.workspace and runner.workspace are incorrect ...
Describe the bug github.Workspace and runner.Workspace don't point to container valid paths when executing inside a container job.
Read more >
Issue: Docker env PATH lost #896 - nektos/act
I was trying to diagnose why a job was failing in act, and couldn't run node inside the container as the PATH was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found