GitHub Actions Unable to Clone secondary Internal Repository Using GITHUB_TOKEN in Workflow – Repository Not Found Error #138818
-
I'm encountering an issue with GitHub Actions while trying to clone an internal repository using the GITHUB_TOKEN in a workflow. The secondary repository exists within the same organization (iEnterpriseInternal/streamline-helm), but the workflow fails with the error:
Workflow Configuration:
Key details:
Steps already taken:
Looking for help on how to resolve this issue and ensure the GitHub Action runner has proper access to clone the secondary repository. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @bhabanistr Here’s how you can resolve the issue and ensure that the GitHub Action runner has the correct access to clone the secondary repository:
The default GITHUB_TOKEN provided in GitHub Actions has limited access to repositories. It only has access to the repository where the workflow is running by default. To allow access to another internal repository within the same organization, you need to configure the permissions properly.
Since you’re working with internal repositories, ensure that you explicitly set the permissions needed for accessing the second repository. You’ve already set the contents: write and pull-requests: write permissions, which is good, but you may need to enable read permissions for the contents as well. Add the following under permissions in the jobs section: permissions:
contents: write
pull-requests: write
packages: read
issues: read
Sometimes, the default GITHUB_TOKEN might not have enough access, especially for cross-repository operations. Using a Personal Access Token (PAT) with more explicit permissions can help resolve the issue.
Replace the token: ${{ secrets.GITHUB_TOKEN }} with token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} in your workflow: - name: Clone secondary repository (streamline-helm)
uses: actions/checkout@v4
with:
repository: iEnterpriseInternal/streamline-helm
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
ref: dev
path: streamline-helm
Double-check that the secondary repository (iEnterpriseInternal/streamline-helm) is accessible to the organization and allows the workflow in your primary repository to access it.
Make sure the “Actions permissions” in the organization settings are configured to allow workflows in one repository to access other repositories. To check this:
GitHub is case-sensitive in repository names. Double-check that the repository name (iEnterpriseInternal/streamline-helm) and the branch name (dev) are correctly spelled and matched exactly as they are in GitHub.
As a last step, try running a similar git clone command locally using the GITHUB_TOKEN or PAT to see if there are any additional issues, such as incorrect permissions or other repository access problems. Example Updated Workflow: name: Dev API Deployment
on:
workflow_dispatch:
push:
branches:
- dev_update
jobs:
dev_build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
packages: read
issues: read
steps:
- name: Checkout primary repository
uses: actions/checkout@v4
with:
ref: dev_update
path: ie-network-api
- name: Clone secondary repository (streamline-helm)
uses: actions/checkout@v4
with:
repository: iEnterpriseInternal/streamline-helm
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # Use PAT instead of GITHUB_TOKEN
ref: dev
path: streamline-helm I really hope this solves your issue. |
Beta Was this translation helpful? Give feedback.
-
Hey there! 👋 Thanks for posting in the GitHub Community, @bhabanistr ! We're happy you're here. You are more likely to get a useful response if you are posting your question in the applicable category. The Accessibility category is a place for our community to discuss and provide feedback on the digital accessibility of GitHub products. Digital accessibility means that GitHub tools, and technologies, are designed and developed so that people with disabilities can use them. I've gone ahead and moved this to the correct category for you. Good luck! |
Beta Was this translation helpful? Give feedback.
Hi @bhabanistr
I am not 100% sure this will help you, but I had pretty much the same issue and solved this as below.
The issue you’re encountering while trying to clone a secondary repository using GitHub Actions and the GITHUB_TOKEN is most likely related to permissions and access rights between repositories within the same organization.
Here’s how you can resolve the issue and ensure that the GitHub Action runner has the correct access to clone the secondary repository:
The default GITHUB_TOKEN provided in GitHub Actions has limited access to repositories. It only has access to the repository where the workflow is running by default. To allow access t…