1

I'm trying to create an auto-deploy file for laravel project.

Here is my code of the yml file. jobs: deploy:

runs-on: ubuntu-latest

steps:
- name: Checkout
  uses: actions/checkout@v2 
- name: Deployment
  uses: appleboy/ssh-action@master
 
  with:
    host: ${{ secrets.SSH_HOST }}
    key: ${{ secrets.SSH_PRIVATE_KEY }}
    username: ${{ secrets.SSH_USERNAME }}
    script: |
      cd path-to-my-directory

      git pull
      php artisan migrate

git pull returns could not read Username for 'https://github.com': No such device or address error. But I sure that username, key, host are set properly. Can't solve the problem or find a similar issue with solution

Takhtak Team
  • 131
  • 1
  • 2
  • 10

1 Answers1

1

If you set an SSH key, while your URL is an HTTPS one, said key would not be used. At all.

Instead, Git, in the GitHub Action, would try and get the credentials (username/password) for the private repository through HTTPS.

Plus, an SSH URL would use the username git anyway, alongside the private SSH key which allows the remote server to authenticate the actual user.

You can see here an example of a GitHub Action actually using an SSH URL:

on: [push]

jobs:
  try-ssh-commands:
    runs-on: ubuntu-latest
    name: SSH MY_TEST
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: test_ssh
        uses: ./
        with:
          ssh_key: ${{secrets.SSH_PRIVATE_KEY}}
          known_hosts: ${{secrets.SSH_KNOWN_HOSTS}}

If you are using HTTPS however, and as noted in the comments be the OP:

  • you need a PAT (Personal Access Token)
  • you need to store it: git config credential.helper store + git pull.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • As I noticed Github not using a username password pair actually. if I want to pull manually I have to use Personal access tokens. But the issue I fixed by running `git config credential.helper store` and the `git pull` manually. after that the workflow runs as expected – Takhtak Team Sep 21 '21 at 20:04
  • @TakhtakTeam Great, well done. I have included your comment in the answer for more visibility. – VonC Sep 21 '21 at 20:10
  • I got something similar working [here](https://stackoverflow.com/a/76961475/1964277) – rupweb Aug 23 '23 at 12:45
  • @rupweb Nice. That should too indeed. – VonC Aug 23 '23 at 14:30