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

possible to checkout or clone another repo? #24

Closed
ChrisChiasson opened this issue Aug 27, 2019 · 22 comments
Closed

possible to checkout or clone another repo? #24

ChrisChiasson opened this issue Aug 27, 2019 · 22 comments

Comments

@ChrisChiasson
Copy link

ChrisChiasson commented Aug 27, 2019

I noticed the documentation for actions says I can't call an action in another private repo that I own. I have a different question. Is it possible to use the checkout action (of my repo) to checkout a public repo, or a private repo owned by me? This would be useful for pulling the latest version of C++ boost header libraries, or another library I wrote that's needed for the build.

@TingluoHuang
Copy link
Member

Yes, you can

steps:
- uses: actions/checkout@master
  with:
    name: org1/repo1     <-- clone https://github.com/org1/repo1
    ref: refs/heads/release

@maxperrimond
Copy link

I tried to clone another private repository with the action but I only get:

##[error]fatal: repository 'https://github.com/orgname/reponame/' not found

step:

      - name: Check out my other private repo
        uses: actions/checkout@master
        with:
          repository: orgname/reponame

I tried to pass the github token but doesn't change the outcome.

@TingluoHuang
Copy link
Member

@maxperrimond try to generate a PAT and set that as repository secret, use that to clone the extra repository, the GITHUB_TOKEN is scope to the workflow repo.
Ex:

      - name: Check out my other private repo
        uses: actions/checkout@master
        with:
          repository: orgname/reponame
          token: ${{ secrets.my_pat }}

@maxperrimond
Copy link

It worked well. Thanks for your support @TingluoHuang

@ChrisChiasson
Copy link
Author

Thanks

@rogerprz
Copy link

If it's from another source outside of github do we use the full URL?

@hohserg1
Copy link

I want to clone multiple repos for together build. How to prevent deleting of prev-cloned repo?
image
It's my configuration: https://github.com/ElegantNetworking/ElegantNetworkingRoot/blob/master/.github/workflows/gradle.yml
Can anyone help?

@hohserg1
Copy link

Ok, now I solve cloning multiple repos by using path.
But I have a problem with running gradle from inner directory
'cd' command is not work
image

@hohserg1
Copy link

Yeeeeah! Solved! --project-dir is cool!

@orelviz
Copy link

orelviz commented Dec 1, 2020

@hohserg1 can you elaborate on how you solved it? Can you share youre .yml file?

@hohserg1
Copy link

hohserg1 commented Dec 26, 2020

@orelviz yes.
I use a path parameter of actions/checkout to specify cloning location.
https://github.com/ElegantNetworking/ElegantNetworkingRoot/blob/master/.github/workflows/gradle.yml#L21
Next I use a --project-dir command line parameter of gradle to specify root location of gradle workspace
https://github.com/ElegantNetworking/ElegantNetworkingRoot/blob/master/.github/workflows/gradle.yml#L55
Link to this yml been posted above

sembrat pushed a commit to drupal-ckeditor-libraries-group/actions_runner that referenced this issue Jan 23, 2021
@rdreyer-godaddy
Copy link

@rogerprz did you get it to work with a repo outside of github.com?

@blane1988
Copy link

blane1988 commented Mar 10, 2021

@rogerprz did you get it to work with a repo outside of github.com?

I am also wondering if we can clone from another domain besides the one where this action is called. In my case, the domain is githubdev, and I want to clone from regular old github.com.

Currently, this action appends the githubdev domain to the repo arg for the action (org/repo) leading to an incorrect full URL.

@elect86
Copy link

elect86 commented Apr 30, 2021

@hohserg1 How did you manage to get the clone persistent?

@garvit-joshi
Copy link

Can we checkout or clone a gitlab repo?

@CartBlanche
Copy link

Does anyone have a simple example of using both path and clean: false, when trying to checkout another repo at the same level as the currently building repo?
I'm trying to get this..
/currentdev/currentrepo
/currentdev/../siblingrepo
before then building the project in currentrepo.

@mochadwi
Copy link

Can we checkout or clone a gitlab repo?

+1 asking a same questions

@CaseyLabs
Copy link

This is for anyone coming here from a Google search.

If you receive the following error when trying to clone a public git repo with Github Actions (whether it's on Github or Gitlab or elsewhere):

An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'fetch', 'origin', '--tags')
return code: 128
expected return code: 0
stdout: (none)
stderr:
    fatal: unable to connect to github.com:
    github.com[0: 140.82.113.4]: errno=Connection timed out

You need to configure git to clone using HTTPS, and not SSH:

git config --global url.https://github.com/.insteadOf git://github.com/

Example:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      
      - name: Run shell commands
        run: |
          git config --global url.https://github.com/.insteadOf git://github.com/
          git clone https://github.com/githubtraining/hellogitworld.git

@Shindek77
Copy link

It worked well. Thanks for your support @TingluoHuang
For me getting below issue: Any suggestions
Error: fatal: could not read Username for 'https://github.com/': terminal prompts disabled

Kuoste added a commit to Kuoste/LasUtility that referenced this issue Jun 11, 2024
trying to clone LasZipNetStandard
actions/checkout#24
@pa-0
Copy link

pa-0 commented Aug 2, 2024

I see multiple people asking whether custom git URL's can be checked out but don't think anyone posted a solution. Has anyone figured this out?

@sudhraja
Copy link

@maxperrimond try to generate a PAT and set that as repository secret, use that to clone the extra repository, the GITHUB_TOKEN is scope to the workflow repo. Ex:

      - name: Check out my other private repo
        uses: actions/checkout@master
        with:
          repository: orgname/reponame
          token: ${{ secrets.my_pat }}

Doesn't work with the latest fine grained token access. Had to do a classic token generation method. Ref #1796

@jigar-joshi-nirmata
Copy link

@maxperrimond try to generate a PAT and set that as repository secret, use that to clone the extra repository, the GITHUB_TOKEN is scope to the workflow repo. Ex:

  - name: Check out my other private repo
    uses: actions/checkout@master
    with:
      repository: orgname/reponame
      token: ${{ secrets.my_pat }}

Can we do this without PAT?
I do not want to use PAT, can I use the GITHUB_TOKEN within workflow itself and eliminate PAT?

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