So I'm trying to pull a branch from one of my private repositories into GitHub Actions, so I can modify it and push it back into that repository, but it won't let me. Although I can clone the repo, but since I need to push modified files back into the repository, that won't work. The workflow that I ran the commands on, runs on ubuntu-latest
. Another thing to note is that when I ran these same commands on my Windows computer, everything runs properly, but for some reason, I didn't need the token or username for the link to work. When I try to pull from the remote repo, I get the following error.
remote: Repository not found.
fatal: repository 'https://github.com/[username]/[repo].git/' not found
Error: Process completed with exit code 1.
But when I try to clone the repository, the command successfully runs. The commands I ran are below.
I create the remote repo with
git remote add repo https://[username]:[token]@github.com/[username]/[repo].git
The token has the repo
scope, so it has complete access to repositories. To verify that the command worked, I ran
git remote -v
Which shows the new remote that I added so I know it worked. Next I try to pull the master
branch from the remote repo with
git pull repo master --allow-unrelated-histories
Which is where I get the error. The clone command is
git clone https://[username]:[token]@github.com/[username]/[repo].git
This command runs successfully unlike the git pull
command.
I have looked at Git - remote: Repository not found and Git Clone - Repository not found, but none of the answers I've tried helped me. Since the commands worked on my local computer, it most likely isn't the commands, and is probably something to do with how GitHub Actions runs the commands or the token.
What I did for the problem to occur
- Create a private repository.
- Add files, commit, push, etc.
- Create a public repository.
- Add a workflow file.
- Create a personal access token with the
repo
scope. - Add a secret in the public repo and set it to
https://[username]:[token]@github.com/[username]/[private repo].git
- Add the commands
git remote add repo ${{ secrets.[secret name] }}
,git remote -v # To verify that the remote add worked
,git pull repo [main/master branch]
, andls
- commit and push the workflow file and then run the workflow.
- Open the session log to see the error