ssh-deploy
ssh-deploy copied to clipboard
Does not run command in ssh?
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 &
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 &
@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 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 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.
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.
I've added support to execute script(s) before and after rsync. https://github.com/easingthemes/ssh-deploy#10-script_after-optional-default-
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?
yes, both scripts are executed on remote machine
SCRIPT_BEFORE:
SCRIPT_AFTER: