Github Actions remote repo issues

I am using Github and I need to implement a feature using Github Actions as per below:

I have two repos - one private and one public. Whenever a pull request is created for ‘master’ branch on the public reposity we need to push the source branch (altogether) into the private repository.

My workflow file looks like below:

  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        env:
         INTERVIEW_TOKEN: ${{ secrets.INTERVIEW_TOKEN }}
        run: |
          echo ${{github.head_ref}}
          git remote -v 
          git fetch
          git checkout ${{github.head_ref}}
          git remote add private-origin https://stoicad:$INTERVIEW_TOKEN@github.com/stoicad/interview-private.git
          git remote -v 
          git push -u private-origin ${{github.head_ref}}

It should be pretty straightforward:

  • fetch from origin
  • checkout PR ‘source’ branch
  • set a new remote (called private-origin) - the generated token has all permission!
  • check to see if the new remote was set
  • push changes to private-repo

The actual result:

PR_TEST_BRANCH
origin  https://github.com/stoicad/interview (fetch)
origin  https://github.com/stoicad/interview (push)
From https://github.com/stoicad/interview
 * [new branch]      PR_TEST_BRANCH -> origin/PR_TEST_BRANCH
 * [new branch]      master         -> origin/master
Previous HEAD position was 7607d53 Merge e1fa33b54d0611dd0b5c5ccfe86d9d00442cdcbb into f882b0a96f557dfe1614fb79920799167b1963a7
Switched to a new branch 'PR_TEST_BRANCH'
Branch 'PR_TEST_BRANCH' set up to track remote branch 'PR_TEST_BRANCH' from 'origin'.
origin  https://github.com/stoicad/interview (fetch)
origin  https://github.com/stoicad/interview (push)
private-origin  ***github.com/stoicad/interview-private.git (fetch)
private-origin  ***github.com/stoicad/interview-private.git (push)
remote: Repository not found.
fatal: repository 'https://github.com/stoicad/interview-private.git/' not found
Error: Process completed with exit code 128.

Am I missing something? Both repositories were created by myself, the generated token has for sure all the rights, what else can be? Why it throws an error saying “Repository not found”?