Home > Enterprise >  How to checkout a repository outside of the workspace in GitHub Actions?
How to checkout a repository outside of the workspace in GitHub Actions?

Time:05-26

I have a repo and where I have created self-hosted runner on windows server 2019.

I want to clone the repo to a different folder than the workspace.

As I linked many things there.

steps:
  # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
  - uses: actions/checkout@v3
    with:
     path: c:\git\myfolder

I tried like above by providing path parameter. But got error as below.

Error: Repository path 'c:\git\myfolder' is not under 'C:\actions-runner\test

I tried the below workflow but still clones to the default folder only.

steps:
  # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
  - uses: GuillaumeFalourd/clone-github-repo-action@v3
    with:
      owner: myname
      repository: myrepo
      path-to-clone: c:\git\myrepo

Also getting this error.

bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No such file or directory
Error: Process completed with exit code 128.

Any suggestions?

CodePudding user response:

Cloning outside of your workspace is currently not possible and there's an open issue in actions/checkout.

They suggest the workaround to add a run step after the checkout and move the checked out folder:

steps:
  - uses: actions/checkout@v3
  - run: mv /path/to/my/folder /path/to/my/target

CodePudding user response:

Try this: https://github.com/GuillaumeFalourd/clone-github-repo-action/issues/3

uses: GuillaumeFalourd/clone-github-repo-action@v3
  with:
    owner: <owner>
    repository: <repo-name>
    path-to-clone: <path/to/clone>
  • Related