Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Action: Default branch not found on privat repository

I have a private repo I need to checkout and use in another private repo. So inside the workflow I'm doing this:

  - name: Checkout small private repo
    uses: actions/checkout@v2
    with:
      repository: name/smallprivaterepo         
      path: build/

I tried using ${{ secrets.REPO_ACCESS_TOKEN }} and env: GITHUB_TOKEN without success.

Determining the default branch
  Retrieving the default branch name
  Not Found
  Waiting 18 seconds before trying again
  Retrieving the default branch name
  Not Found
  Waiting 13 seconds before trying again
  Retrieving the default branch name
  Error: Not Found

The default branch on the private repo i'm trying to fetch is master. When adding ref: master to the .yml I get:

  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/master*:refs/remotes/origin/master* +refs/tags/master*:refs/tags/master*
  Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled
  The process '/usr/bin/git' failed with exit code 128
  Waiting 12 seconds before trying again
like image 660
Mike Avatar asked Sep 21 '25 10:09

Mike


1 Answers

OK, i made it work, but i don't know if thats the secure way to do it.

So I already had a PAT in my developer settings: https://github.com/settings/tokens

Then I added a secret named MYPAT to the repo that is trying to checkout the private repo. That secret contains the PAT token!

Then only added this to the yml:

token: ${{ secrets.MYPAT }}

So the PAT token is actually saved twice in github.

like image 184
Mike Avatar answered Sep 23 '25 10:09

Mike