Skip to content

Unable to clone outside of GITHUB_WORKSPACE directory #197

Open

Description

@eabuslaiman30

Hi Guys. I have a directory where the source code is located. I'm trying to create an action to:

  1. Pull the last code on that directory (example /home/my-code/src)
  2. Run npm install on that directory
  3. Run npm run build on that directory.

Anyway, I set the env var $GITHUB_WORKSPACE into my yml file, but it seems to be not respecting the directory where the code is cloned / pulled in.

My script:

name: Development Deploy

on:
  push:
    branches: [ develop ]

jobs:
  build:

    runs-on: self-hosted

    strategy:
      matrix:
        node-version: [10.10.0]
    steps:
      - name: Updating base code from develop
        uses: actions/checkout@v2
        with:
          ref: refs/heads/develop
          GITHUB_WORKSPACE: /home/my-code/src

    ... Another steps here

The log says the following:

Added matchers: 'checkout-git'. Problem matchers scan action output for known warning or error strings and report these inline.
Syncing repository: repoowner/reponame
Working directory is '/etc/actions-runner/website/src/reponame'

Is there anyway I can use the existing directory to use the checkout action? I want this to be cloned on /home/my-code/src

Thanks

Activity

  1. jsg2021 commented on Mar 25, 2020

    @jsg2021

    I could be wrong, but I think that's a reserved variable that already has meaning in this system.

  2. jsg2021 commented on Mar 25, 2020

    @jsg2021

    Why do you need to specify where the code is cloned? This action takes care of that for you.

  3. ericsciple commented on Mar 25, 2020

    @ericsciple
    Contributor

    Today the path input is the only way to change the directory where the code is cloned. Also there is a restriction that it must be under GITHUB_WORKSPACE. If you want to get around that limitation, you could add a run step to move or copy the folder - or soft/hard link too i guess but but might unexpected issues later 🤷‍♂

  4. eabuslaiman30 commented on Mar 25, 2020

    @eabuslaiman30
    Author

    So we're running a self-hosted runner, so the runner is in /etc and we don't want our code to be on that location. @jsg2021

    Thanks @ericsciple . The limitation with path parameter is as you said, it needs to be under GITHUB_WORKSPACE. Tried with absolute paths and ../../{blabla} but error hapenned.

  5. changed the title [-]Clone does not respect variable GITHUB_WORKSPACE[/-] [+]Unable to clone outside of GITHUB_WORKSPACE directory[/+] on Mar 25, 2020
  6. ddrinka commented on Sep 1, 2020

    @ddrinka

    This is important functionality for our builds because we have long repository names. We're getting paths like:
    D:\a\VeryLongRepositoryNameAAAAAAAAAAAAAAAAAAA\VeryLongRepositoryNameAAAAAAAAAAAAAAAAAAAA\src\ALongProjectNameBBBBBBBBBBBBBBBB\ALongProjectNameBBBBBBBBBBBBBBBB.csproj

    We're hitting MAX_PATH on Windows builds. We need to be able to checkout and build in a directory like: D:\a\s\src\ALongProjectName...

  7. dukeofphilberg commented on Sep 23, 2020

    @dukeofphilberg

    Perhaps you could create a symlink from the github workspace folder (_work by default) to another location.

    image

    This won't help long repository names though..

  8. AzfaarQureshi commented on Oct 5, 2020

    @AzfaarQureshi

    I was running into the same issue, @ericsciple thanks for the workaround suggestion! :)

    do you know if the $GITHUB_WORKSPACE variable can be changed elsewhere?

  9. gengjiawen commented on Oct 19, 2020

    @gengjiawen

    On windows, too

    Run actions/checkout@v2
      with:
        path: C:/nodejs
        repository: gengjiawen/node
        token: ***
        ssh-strict: true
        persist-credentials: true
        clean: true
        fetch-depth: 1
        lfs: false
        submodules: false
      env:
        PYTHON_VERSION: 3.8
        FLAKY_TESTS: dontcare
    Error: Repository path 'C:\nodejs' is not under 'D:\a\node\node'
  10. added 3 commits that reference this issue on Nov 14, 2020
    9136ce8
    021c87e
    edb45c7
  11. moelleru commented on Dec 10, 2020

    @moelleru

    Hi, running into the same issue. Thanks to @LebedevRI for the fix. But any idea when this fix will be available?

  12. nitin-jci commented on Dec 22, 2020

    @nitin-jci

    I tried configuring self hosted runner as suggested by @pvanloo in above [comment] (#197 (comment)) and it worked for me.

    If someone needs a specific workspace, I would suggest to give a try with self hosted runner and specify your workspace path in work folder configuration.

  13. 32 remaining items

  14. jakoch commented on Sep 19, 2023

    @jakoch

    what is the workaround? fetch the branch as zip and extract into outside of workspace folder?

    seems mv folder ..

  15. Hecatron commented on Sep 19, 2023

    @Hecatron

    what is the workaround? fetch the branch as zip and extract into outside of workspace folder?

    I put a workaround further up

    One workaround might be to create a symbolic link
    So under windows after the checkout for example

          - name: Link working directory
            run: New-Item -Path D:/rust -ItemType SymbolicLink -Value D:/a/rust-build/rust-build
    

    That way a shorter path can be used.
    Under Linux it'd be "ln -s" instead

    That way you can for example extract things into D:/a/rust-build/rust-build, but then do any compiling via D:/rust as they both point to the same place

  16. ManikantaVenkateshappa commented on Sep 19, 2023

    @ManikantaVenkateshappa

    what is the workaround? fetch the branch as zip and extract into outside of workspace folder?

    Please check if this helps: #197 (comment)

  17. accodev commented on Nov 24, 2023

    @accodev

    I have made this PR #1493 exactly for this issue.

  18. WiehanVanNiekerk commented on Feb 23, 2024

    @WiehanVanNiekerk

    I'm doing another follow-up on this request regarding PR #1493

  19. WiehanVanNiekerk commented on Feb 23, 2024

    @WiehanVanNiekerk

    I'm doing another follow-up on this request regarding PR #1493

    @cory-miller, @takost , @luketomlinson

  20. eXpl0it3r commented on Apr 11, 2024

    @eXpl0it3r

    If you have a repository name that ends in a dot, you can't use the checkout action on a Windows runner, because the workspace directory is always the repository name, but Windows doesn't allow for directory names with a trailing dot...

    For example: M.A.R.S.

  21. HariSekhon commented on Apr 11, 2024

    @HariSekhon

    @eXpl0it3r why don't you just check out to an explicitly specified directory name like mars?

  22. eXpl0it3r commented on Apr 11, 2024

    @eXpl0it3r

    See the issue we're in. I can't clone anywhere else other than the $GITHUB_WORKSPACE which is also the repo name (i.e. M.A.R.S.), which again can't be created on a Windows agent due to the trailing dot.

  23. HariSekhon commented on Apr 11, 2024

    @HariSekhon

    You may have missed the workaround in my comment further above:

    I've worked around GITHUB_WORKSPACE by doing a manual git clone using commands since this action hardly saves any code anyway, which you can see in the link I posted above to my public GitHub Actions repository.

    If you do a git clone in a shell run step you can put it anywhere you want and with any directory name you want as an extra arg to the git clone command.

    Or is the problem you're having that the agent fails to spawn properly as it tries to pre-create the $GITHUB_WORKSPACE directory which fails even without using a checkout action?

  24. eXpl0it3r commented on Apr 11, 2024

    @eXpl0it3r

    That's possible indeed, I mostly wanted to report this additional limitation/issue with the Action as is

  25. nightlark commented on Nov 19, 2024

    @nightlark

    I ran into issues using actions/checkout to clone a 2nd repository related to the .git subfolders conflicting, so I tried cloning into a directory in a tmp dir outside of GITHUB_WORKSPACE, which failed due to this issue. The git exit codes aren't really that informative of what is going on -- it would be nice if actions/checkout could give a better error message related to corner cases where it fails, such as cloning a git repository into a subfolder of another git repository (not talking about git submodules, just fetching another unrelated repository as a test for another piece of code).

  26. added a commit that references this issue on Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions