Search code examples
githubgithub-actions

Checkout a specific branch - Not Found error in github actions


My scenario: I am in a repo1 (that is where I have this workflow file) and trying to pull repo 2 (both are in the same organization) from repo 1 with the following code:

- name: Checkout aaa-frontend repo
  uses: actions/checkout@v2
  with:
    repository: Orgn1-Global/aaa-frontend
    path: develop
    token: ${{ github.token }} 

From the below error, I assume that, it is able to locate the repository but only has a problem in locating the branch. Is this correct?

Run actions/checkout@v2
Syncing repository: Orgn1-Global/aaa-frontend
Getting Git version info
Initializing the repository
Disabling automatic garbage collection
Setting up auth
Determining the default branch
  Retrieving the default branch name
  Not Found
  Waiting 17 seconds before trying again
  Retrieving the default branch name
  Not Found
  Waiting 12 seconds before trying again
  Retrieving the default branch name
  Error: Not Found

and what's the right way to pull the 'main' branch of repo 2 from this repo 1?


Solution

  • If I understand your requirement correctly, do you want to checkout repo1 and repo2 in the repo1 action workflow ?

    If Yes - It has to be like this:

    # checkout of repo1 - where you have your workflow file
    - name: Checkout
      uses: actions/checkout@v2
      with:
        path: main
    # checkout repo2 in a folder called my-tools
    - name: Checkout tools repo
      uses: actions/checkout@v2
      with:
        repository: my-org/repo2
        path: my-tools
    

    you can always find an awesome examples in Github action public repository. Here is the checkout one.