actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.98k stars 1.77k forks source link

Repository not found - Checkout specific repo #853

Open klepiz opened 2 years ago

klepiz commented 2 years ago

Im trying to checkout multiple repos in a same job, one of them if where Im running the job and the second one is an internal repo.

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      -  uses: actions/checkout@v2 
        with:
          ref: ${{ secrets.GITHUB_REF }}
          repository: my-org/my-repo
          path: my-repo
          fetch-depth: 0

The error that I got:

 remote: Repository not found.
  Error: fatal: repository 'https://github.com/my-org/my-repo/' not found
  The process '/usr/bin/git' failed with exit code 128
  Waiting 15 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/testing-workflows*:refs/remotes/origin/testing-workflows* +refs/tags/testing-workflows*:refs/tags/testing-workflows*
  remote: Repository not found.
pbasista commented 2 years ago

The root cause of this behavior seems to be summarized by the following note:

https://github.com/actions/checkout/blob/2541b1294d2704b0964813337f33b291d3f8596b/action.yml#L68-L69

It is necessary to provide some credentials for accessing the my-org/my-repo private repository to this action while allowing it to successfully checkout the repository on which the action itself runs. I am unsure how to do that properly in the same step based on this action.

One option might be to use the personal access token which would have the rights to both the repository on which the action runs, as well as to the other private repository. But it is unclear to me whether it can be done with SSH keys instead.

Related issue: #924.

gg-oura commented 1 month ago

if you provide ssh-key with an empty value it will still use https. One scenario where this can occur is if you are calling actions from another action (e.g. workflow-call) and you don't pass the secret from the parent action. You might have ssh-key: ${{ secrets.KEY}} but it will do nothing if you don't pass secrets as a inputs.secrets