easingthemes / ssh-deploy

GitHub Action for deploying code via rsync over ssh. (with NodeJS)
MIT License
1.17k stars 144 forks source link

SCRIPT_AFTER sometimes not running, especially when rsync is large #113

Closed hxkenneth closed 1 year ago

hxkenneth commented 1 year ago

It seems like the script-after shell script is created correctly but not running. I know it did not run because the script is supposed to take my app out of maintenance mode as well as update permissions on some dirs, all of which are not done.

This only happens sometimes, in particular when there are a large number of files to update through rsync.

sent 125,332,449 bytes  received 24,143 bytes  4,398,476.91 bytes/sec
total size is 292,186,536  speedup is 2.33

✅ [DIR] /home/runner/work/xxx/xxx dir exist
[FILE] writing /home/runner/work/xxx/xxx/local_ssh_script-after.sh file ... 366
Executing remote script: ssh -i /home/runner/.ssh/deploy_key_***_1675522390655 ***@***
spawn E2BIG
domstubbs commented 1 year ago

I’ve noticed the same thing. My initial deployments all failed to run the post-deploy script, but subsequent releases with smaller changesets have been fine.

I haven’t tested it, but since this seems to be tied to output length perhaps a quieter rsync config would help (e.g. removing -i).

hxkenneth commented 1 year ago

That makes sense, I'll give it a go. Currently I have it configured to ignore many folders which contain rarely changed assets which is a pain as you can imagine when the files do end up changing.

easingthemes commented 1 year ago

Thanks for checking. I've added a limit to RSYNC_STDOUT which is passed to the script. Not sure what limit to take, for now I've used 10000 chars. Let me know if it's still breaking.

tmlmt commented 9 months ago

I've just faced a similar issue. I've tested my SCRIPT_AFTER (manual copy paste of each command works), but it doesn't get executed despite the log showing the following:

✅ [DIR] /home/runner/work/***vue/***vue dir exist
[FILE] writing /home/runner/work/***vue/***vue/local_ssh_script-after-767d8910-4a9e-4eae-b221-65546015fca9.sh file ... 165
Executing remote script: ssh -i /home/runner/.ssh/deploy_key_***_1701055218186 ***@***

I was not taking advantage of rsync before and was deleting my target directory in SCRIPT_BEFORE, which resulted in a long rsync. Not deleting it (and thefore reducing rsync time/output) led to SCRIPT_AFTER being executed (the log continues after the above snippet and outputs the sdout of the script).

Any idea why this is happening and how to make this Action more robust?