Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lemmon's avatar
Level 28

Github actions push to deploy

Has anyone followed this and made it work? https://laravel-news.com/push-deploy-with-github-actions

0 likes
6 replies
lemmon's avatar
Level 28

@bobbybouwmann Thank you for responding.

I have a digitalocean droplet using LAMP stack that I am using ssh and a key without passphrase to log onto.

ubuntu 20.04 apache mysql php

I have tested the install and it is functional the virtual host I have configured on the server devlemmon.com and public is root.

i have this script in the repository 'server_deploy.sh'

#!/bin/sh
set -e

echo "Deploying application ..."

# Enter maintenance mode
(php artisan down --message 'The app is being (quickly!) updated. Please try again in a minute.') || true
    # Update codebase
    git fetch origin deploy
    git reset --hard origin/deploy

    # Install dependencies based on lock file
    composer install --no-interaction --prefer-dist --optimize-autoloader

    # Migrate database
    php artisan migrate --force

    # Note: If you're using queue workers, this is the place to restart them.
    # ...

    # Clear cache
    php artisan optimize

    # Reload PHP to update opcache
    echo "" | sudo -S service php7.4-fpm reload
# Exit maintenance mode
php artisan up

echo "Application deployed!"

I have 'deploy.sh' in the local version on my computer.

#!/bin/sh
set -e

vendor/bin/phpunit

(git push) || true

git checkout production
git merge master

git push origin production

git checkout master

I created the action '.github/workflows/main.yml'

name: CD

on:
  push:
    branches: [ production ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        token: ${{ secrets.PUSH_TOKEN }}
    - name: Set up Node
      uses: actions/setup-node@v1
      with:
        node-version: '12.x'
    - run: npm install
    - run: npm run production
    - name: Commit built assets
      run: |
        git config --local user.email "[email protected]"
        git config --local user.name "GitHub Action"
        git checkout -B deploy
        git add -f public/
        git commit -m "Build front-end assets"
        git push -f origin deploy
    - name: Deploy to production
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.KEY }}
        port: ${{ secrets.PORT }}
        script: 'cd /var/www/devlemmon.com && ./server_deploy.sh'

I set up the 5 secrets that are needed in mail.yml

it goes as far as to properly create deploy branch with the needed files.

I think it is failing on the Deploy to production that uses appleboy/ssh-action@master

the the folder on the server is 'devlemmon.com' and it contains a public directory. the document root is public. the name of the repo I am using is called 'fortify'

Question: do the repo and the name of the site have to be the same?

Question: how can I debug the connection?

Thank you for your help.

here is the repo https://github.com/henrylemmon/fortify

lemmon's avatar
Level 28

here is the error;

2020/10/21 00:15:49 ssh.ParsePrivateKey: ssh: no key found
======CMD======
cd /var/www/*** && ./server_deploy.sh
======END======
2020/10/21 00:15:50 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain
lemmon's avatar
Level 28

yes sir @bobbybouwmann I copied the private key into the secret.

and I used the hostname devlemmon.com. it is failing the handshake with the same creds that I use to ssh with putty.

Here is the latest error:

2020/10/21 23:37:10 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

lemmon's avatar
Level 28

I have spent a week on this and read everything two or three times that I could find on the subject from git actions, secrets, creating and storing keys, etc.

It could just be that i am on a windows machine using git bash and putty and puttygen. I am sure that I will figure this out at some point.

thank you all for your help.

Please or to participate in this conversation.