ad-m / github-push-action

GitHub actions to push back to repository eg. updated code
MIT License
1.21k stars 230 forks source link

"fatal: Authentication failed" #142

Closed Xylambda closed 2 years ago

Xylambda commented 2 years ago

Hi,

I am unable to make this action push to a gh-pages branch despite the fact that everything seems to be well configured. (Probably is my lack of knowledge, TBH):

Error Output:

Run ad-m/github-push-action@v0.6.0
Started: bash /home/runner/work/_actions/ad-m/github-push-action/v0.6.0/start.sh
Push to branch gh-pages
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Xylambda/kalmankit.git/'
Error: Invalid status code: 128
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/v0.6.0/start.js:9:19)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) {
  code: 128
}
Error: Invalid status code: 128
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/v0.6.0/start.js:9:19)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)

yml file and repo

This is the repo and this is the actions file, which a I copy-paste below:

name: github pages

on:
  push:
    branches:
      - master
      - develop

jobs:
  build_docs_job:
    runs-on: ubuntu-latest
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Python Set Up
        uses: actions/setup-python@v2.2.1
        with:
          python-version: 3.8

      - name: Upgrade pip
        run: |
          # install pip=>20.1 to use "pip cache dir"
          python3 -m pip install --upgrade pip

      - name: Install dependencies
        run: |
          python3 -m pip install . -r requirements-dev.txt

      - name: Make Sphinx docs
        run: |
          make -C docs clean
          make -C docs html

      - name: Init new repository in dist folder and commit generated files
        run: |
          cd docs/build/html/
          git init
          git config --global --add safe.directory /github/workspace/docs/build/html
          touch .nojekyll
          git add -A
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git commit -m 'deploy'

      - name: Force push to destination branch
        uses: ad-m/github-push-action@v0.6.0
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}$
          branch: gh-pages
          force: true
          directory: ./docs/build/html

Permissions

The Actions permissions seem to also be okey:

Screenshot

I am pretty sure this is not a bug (in this action), but I cannot really understand why this is not working.

Thanks in advance.

ZPascal commented 2 years ago

Hi @Xylambda, I'll recommend using the master version of the action to use the newest stable version of the push functionality. The error looks like that you use the wrong credentials (password) instead of the token. Could you please check the used credentials on your side inside the repository and maybe create custom personal access token and use as a GitHub Secret?

Xylambda commented 2 years ago

Hi, thanks for the quick response.

I am gonna list some things and changes that I've tried:

name: github pages

on:
  push:
    branches:
      - master
      - develop

jobs:
  build_docs_job:
    runs-on: ubuntu-latest
    env:
      GITHUB_PAT: ${{ secrets.PUSH_TOKEN }}

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Python Set Up
        uses: actions/setup-python@master
        with:
          python-version: 3.8

      - name: Upgrade pip
        run: |
          # install pip=>20.1 to use "pip cache dir"
          python3 -m pip install --upgrade pip

      - name: Install dependencies
        run: |
          python3 -m pip install . -r requirements-dev.txt

      - name: Make Sphinx docs
        run: |
          make -C docs clean
          make -C docs html

      - name: Init new repository in dist folder and commit generated files
        run: |
          cd docs/build/html/
          git init
          git remote add origin https://${{ secrets.PUSH_TOKEN }}$@github.com/Xylambda/kalmankit
          git config --global --add safe.directory /github/workspace/docs/build/html
          touch .nojekyll
          git add -A
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git commit -m 'deploy'

      - name: Force push to destination branch
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.PUSH_TOKEN }}$
          branch: gh-pages
          force: true
          directory: ./docs/build/html

Nothing seems to work. The yml file is not using, as far as I am concerned, any password authetication.

ZPascal commented 2 years ago

Hi @Xylambda, could you please remove on both sides here and here the corresponding $ at the end of the env variable/ secret usage.

Xylambda commented 2 years ago

Well, that did the trick. I feel kind of silly. Thank you very much for your time and help @ZPascal

Feel free to close the issue since it is solved.