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_WORKSPACE and github.workspace are different when running in container #785

Closed
nkakouros opened this issue Apr 26, 2022 · 8 comments

Comments

@nkakouros
Copy link

When using a container to run the checkout, the variables ${{ GITHUB_WORKSPACE }} and ${{ github.workspace }} are different.

---

name: CI

on:  # yamllint disable-line rule:truthy
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

  workflow_dispatch: ~

jobs:
  test:
    runs-on: ubuntu-latest
    container:
      image: ubuntu:latest
    steps:
      - uses: actions/checkout@v3
      - run: |
          echo ${{ github.workspace }}
          echo $GITHUB_WORKSPACE

The documentation for github.workspace says:

The default working directory on the runner for steps, and the default location of your repository when using the checkout action.

The documentation for GITHUB_WORKSPACE says:

The default working directory on the runner for steps, and the default location of your repository when using the checkout action.

I believe they should be set to the same value.

@alexprogrammr
Copy link

I'm facing the same issue using containers.

$ echo ${{ github.workspace }}
/home/runner/work/<REPO_NAME>/<REPO_NAME>

$ echo $GITHUB_WORKSPACE
/__w/<REPO_NAME>/<REPO_NAME>

where <REPO_NAME> is the repository name where workflow is running.

@spikeburton
Copy link

Interesting observation -

- run: |
    echo ${{ github.workspace }}

    MY_WORK_DIR=${{ github.workspace }}
    echo "MY_WORK_DIR=$MY_WORK_DIR" >> $GITHUB_ENV
- run: |
    echo $MY_WORK_DIR

Output:

+ echo ${{ github.workspace }}
/opt/actions-runner/_work/<REPO_NAME>/<REPO_NAME>

+ echo $MY_WORK_DIR
/__w/<REPO_NAME>/<REPO_NAME>

@ZachOldham
Copy link

I don't think this is a checkout specific bug actions/runner#2058

@nkakouros
Copy link
Author

Indeed, closing this and subscribing to the linked bug.

@abhijeetdhoke
Copy link

I am getting same issue can someone help me on this? its killing my time

@gitcos
Copy link

gitcos commented Sep 19, 2023

Indeed, closing this and subscribing to the linked bug.

What is "the linked bug"? You didn't link to another bug.

@mloskot
Copy link

mloskot commented Sep 19, 2023

I guess it was meant to be the bug linked by previous #785 (comment) that is this one actions/runner#2058

hkershaw-brown added a commit to hkershaw-brown/DART that referenced this issue Jun 12, 2024
pthierry-ledger added a commit to outpost-os/action-setup-compiler that referenced this issue Aug 2, 2024
pthierry-ledger added a commit to outpost-os/action-setup-compiler that referenced this issue Aug 2, 2024
daprilik added a commit to microsoft/openvmm that referenced this issue Oct 18, 2024
Very frustrating indeed... Running into
actions/checkout#785
@Matthew0x
Copy link

Matthew0x commented Jan 27, 2025

I'm facing the same issue using containers.

$ echo ${{ github.workspace }}
/home/runner/work/<REPO_NAME>/<REPO_NAME>

$ echo $GITHUB_WORKSPACE
/__w/<REPO_NAME>/<REPO_NAME>

where <REPO_NAME> is the repository name where workflow is running.

Apparently it's slightly different now (at least in my case), yet the documentation and the issue remain the same.
For instance:

echo ${{ github.workspace }} gives /runner/_work/<REPO_NAME>/<REPO_NAME>
echo $GITHUB_WORKSPACE gives /__w/<REPO_NAME>/<REPO_NAME>
And ${{ github.workspace }} doesn't work in containers, but the other one does (if you mean to reference the repository artifacts).

PS: I left my comment here, because there is a solution and it does involve the checkout action, even if it's a runner issue. Just use the system variable and not the template syntax. That worked for me.

joshua-clayton added a commit to joshua-clayton/cocogitto-action that referenced this issue Feb 20, 2025
${{github.action_path}} is not compatible with container based actions.
${{github.workspacei}} suffers from the same defect, and it is unlikely that
 github is going to fix it, as it has been a known issue for a long time.
See actions/checkout#785

The solution is to use ${{env.GITHUB_ACTION_PATH}} instead, or inside
a run context, just $GITHUB_ACTION_PATH
oknozor pushed a commit to cocogitto/cocogitto-action that referenced this issue Mar 4, 2025
${{github.action_path}} is not compatible with container based actions.
${{github.workspacei}} suffers from the same defect, and it is unlikely that
 github is going to fix it, as it has been a known issue for a long time.
See actions/checkout#785

The solution is to use ${{env.GITHUB_ACTION_PATH}} instead, or inside
a run context, just $GITHUB_ACTION_PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants