Checkout: possible to checkout or clone another repo?

Created on 28 Aug 2019  路  14Comments  路  Source: actions/checkout

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.

Most helpful comment

@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 }}

All 14 comments

Yes, you can

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

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.

@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 }}

It worked well. Thanks for your support @TingluoHuang

Thanks

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

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?

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

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

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

@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

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

@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.

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

Was this page helpful?
0 / 5 - 0 ratings