GitHub Actions - Unable to push to private repository from workflow (Repository not found)

Hey,

I have a GitHub Actions workflow which generates some files automatically in the CI and needs to push back to the repository.

Here are the relevant parts of my workflow:

# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Types

on:
    push:
        branches:
            - dev

jobs:
    publish:
        name: 'Publish types'
        runs-on: ubuntu-latest
        permissions:
            contents: read
            packages: write
        env:
            working-directory: ./typings

        steps:
            - uses: actions/checkout@v2
              with:
                  fetch-depth: 0

            - name: Setup user
              uses: oleksiyrudenko/gha-git-credentials@v2-latest
              with:
                  global: true
                  token: '${{ secrets.GITHUB_TOKEN }}'

            - name: Commit changes
              run: |
                  git add .
                  git commit -m "chore(release): types@${{ env.PACKAGE_VERSION }}" || { echo "Nothing to commit"; exit; }
                  git tag -a "types@v${{ env.PACKAGE_VERSION }}" -m "chore(release): types@${{ env.PACKAGE_VERSION }}"

# This fails
#            - name: Push changes
#              uses: ad-m/github-push-action@master
#              with:
#                  github_token: ${{ secrets.GITHUB_TOKEN }}
#                  branch: ${{ github.ref }}
#                  tags: true

# And so does this
#            - name: Push changes
#              run: |
#                  git push --follow-tags

I keep getting an error only in the push stage as follows:

remote: Repository not found.
fatal: repository '<org>/<repo>' not found
Error: Process completed with exit code 128.

Any idea why? It works when I use the same GITHUB_TOKEN to pull the repository, but gives this error when trying to push.

Note:

  • Setting up the user by myself doesn’t help either
  • I’ve tried using Github Actions user and my own GitHub user to no avail
  • I’ve also tried to use my PAT instead of the GITHUB_TOKEN but again to no avail

Did you end up finding a resolution? I’m experiencing the same issue.