In Github Actions, I'm trying to make some changes to a different repo than the repository the workflow belongs to. See this code:
- name: Generate API module
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git clone https://user:$GITHUB_TOKEN@github.com/owner/my-repo # This works
cd my-repo
git config user.name "user"
git config user.email "dev@example.com"
git checkout -b api-version-$COMMIT
touch new-file.sh
git add new-file.sh
git commit -m "Add new file"
git remote -v # Prints:
# origin ***github.com/owner/my-repo.git (fetch)
# origin ***github.com/owner/my-repo.git (push)
git push --set-upstream origin api-version-$COMMIT # This does not work
git push --set-upstream https://user:$GITHUB_TOKEN@github.com/owner/my-repo api-version-$COMMIT # This does not work either
I can clone the owner/repo repository just fine. I can checkout the new branch, add the file and commit the changes. The problem occurs when I try to push the changes upstream. That doesn't work at all, and I get this error:
remote: Repository not found.
fatal: repository 'https://github.com/owner/my-repo/' not found
I'm just guessing that it has something to do with authentication. The GITHUB_TOKEN is a personal access token and has all possible permissions.
What gives?