ssh-deploy icon indicating copy to clipboard operation
ssh-deploy copied to clipboard

Does not run command in ssh?

Open rodriguesfas opened this issue 3 years ago • 4 comments
trafficstars

Does not run command in ssh?

Hello, excellent work this script to deploy, I have used it in PHP project and it has worked wonderfully.

I recently decided to use your deploy script for golang application, it runs perfectly without any error, sends the binary to the server in the specified path.

What happens is a snippet of code I added for it to run the binary in the background. It doesn't run, could you help me find out what I've been doing wrong?

Here's the script I'm using, thank you in advance for your attention. Hug.

name: 🚀 Deploy on push

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: ssh deploy
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          REMOTE_HOST: ${{ secrets.SSH_HOST }}
          REMOTE_USER: ${{ secrets.SSH_USER }}
          REMOTE_PORT: ${{ secrets.HOST_PORT }}
          SOURCE: "/go.realm.com.br"
          TARGET: ${{ secrets.DEPLOY_TARGET }}
          run: |
            cd .. && 
            cd /home/username && 
            chmod +x /home/username/go.realm.com.br && 
            nohup ./go.realm.com.br &

rodriguesfas avatar May 09 '22 10:05 rodriguesfas

It looks to me like it may be an indentation issue. Perhaps this will work?

name: 🚀 Deploy on push

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: ssh deploy
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          REMOTE_HOST: ${{ secrets.SSH_HOST }}
          REMOTE_USER: ${{ secrets.SSH_USER }}
          REMOTE_PORT: ${{ secrets.HOST_PORT }}
          SOURCE: "/go.realm.com.br"
          TARGET: ${{ secrets.DEPLOY_TARGET }}
        run: |
          cd .. && 
          cd /home/username && 
          chmod +x /home/username/go.realm.com.br && 
          nohup ./go.realm.com.br &

zulaica avatar Jun 15 '22 05:06 zulaica

@rodriguesfas were you able to get this to work? Perhaps I'm trying to do something that isn't possible, but I also wanted to run a command immediately after the rsync. As you said, the code in your example deploys successfully, but the command in run appears to not be run.

I tried @zulaica indentation example, but this throws the error that each step can only contain 'uses' or 'run' but not both.

Any help would be appreciated, first time using github actions so not very clear how these work.

ddxv avatar Sep 03 '22 10:09 ddxv

@ddxv Hi friend, I have not pursued the idea of using Go at the moment. I have not tested this solution. Sorry for not being able to help you.

rodriguesfas avatar Sep 04 '22 18:09 rodriguesfas

@rodriguesfas thanks, same here, after spending an hour or so I moved on to another github action (ssh-action) that did support this. Was my first time using github actions, so I think I may have just been improperly trying to use this project, but for pure deploying via rsync it worked very well.

ddxv avatar Sep 10 '22 06:09 ddxv

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jan 01 '23 02:01 github-actions[bot]

I've added support to execute script(s) before and after rsync. https://github.com/easingthemes/ssh-deploy#10-script_after-optional-default-

easingthemes avatar Jan 02 '23 20:01 easingthemes

I've added support to execute script(s) before and after rsync. https://github.com/easingthemes/ssh-deploy#10-script_after-optional-default-

Is it possible to execute a script on the target machine, rather than the host machine?

peterolson avatar Mar 13 '23 15:03 peterolson

yes, both scripts are executed on remote machine

      SCRIPT_BEFORE: 
      SCRIPT_AFTER:

easingthemes avatar Mar 13 '23 20:03 easingthemes