remote: Repository not found in GitHub pipeline
Asked Answered
C

2

11

I'm trying to checkout a private repo inside my GitHub pipeline, and the following is my pipeline code,

build:

runs-on: ubuntu-latest

steps:  
  - name: Checkout pickezy backend
    uses: actions/checkout@v2
    with:
     repository: Madurad/jenkinsfiles
     token: ${{ secrets.GITHUB_TOKEN }}
     ref: master

But when I run this I get the following error saying, "repository not found" but it's in my githiub org. and it's a private repo.

enter image description here

It does not seem like an auth error. Could anyone please help me to resolve this issue? Anything I've missed?

Catrinacatriona answered 2/11, 2021 at 18:38 Comment(0)
D
12

You can add the missing permission in the top level of the YAML file:

permissions:
  contents: read

Note that I did not need to specify token: ${{ secrets.GITHUB_TOKEN }} in the checkout step.

This solution is based on an auto-completion from GitHub Copilot. It works, but I did no further research.

Damaraland answered 3/4, 2023 at 22:8 Comment(0)
B
4

You can observe on the Github documentation that the GITHUB_TOKEN doesn't have all available permissions.

In this specific case, the permission to access the private repository.

If you want to perform specific operations in your workflows involving other permissions, you'll need to create a PAT (Personal Access Token) with the wished permissions and use it instead of the GITHUB_TOKEN (adding it as a secret).


In your case, the workflow will look like this:

build:

runs-on: ubuntu-latest

steps:  
  - name: Checkout pickezy backend
    uses: actions/checkout@v2
    with:
     repository: Madurad/jenkinsfiles
     token: ${{ secrets.PAT }}
     ref: master
Benzine answered 2/11, 2021 at 22:26 Comment(2)
I tried the way you told, but now getting different error "Error: Input required and not supplied: token"Catrinacatriona
Did you create the Personal Access Token and add it as a repository secret? This error occurs generally when the secret is empty.Benzine

© 2022 - 2024 — McMap. All rights reserved.