Hey everyone! I'm currently working on a project that involves deploying a Dockerized web app to a Swarm cluster hosted on Play with Docker, using GitHub Actions for CI/CD. I've managed to make everything work smoothly until I hit a snag with the final deployment step. When I run this command to SSH into the PWD instance and deploy my app:
`ssh -i my_key root@instance_ip "docker stack deploy -c docker-compose.yml myapp"`
it works perfectly from my local machine, but when I try it in GitHub Actions, I get an exit code of 255. The weird part is that I can connect without any issues if I omit the `docker stack deploy` part. I can also transfer files using scp and sftp in my GitHub Actions workflow with no problems. I even tested this on a local GitHub Actions runner, and it failed the same way. I did come across a pre-built SSH action that worked, but I can't use it in this context. I've double-checked file paths, permissions, and shell syntax, and tried various quoting and escaping methods. I'm really stuck here. Has anyone else encountered this issue? Any help would be greatly appreciated!
4 Answers
It sounds like you might need to do some debugging to see if it's just that command causing the issue or if there are broader SSH problems. Try using the debug flag with your SSH command:
`ssh -vvv -i user@host 'command'`
This will give you detailed output that can help identify what might be going wrong. Also, if your command hangs, it could indicate that there's an interaction issue needing more investigation!
Another thing to check is whether your SSH session can accept new host keys since it sounds like you're not getting an interactive shell session. You might try adding flags to ignore host key checking temporarily, and if that works, make sure to fetch the host keys in advance using something like `ssh-keyscan`.
Have you checked the logs? They can be super helpful in diagnosing what's going wrong. If you're getting timeouts or other specific errors, those logs might hold the key to the mystery. Hang in there!
Given that your SSH connects fine without the command, it's likely an issue with the exit code from the Docker command. Have you tried specifying the full absolute path for your compose.yml file? Sometimes Docker expects exact locations, especially in different environments.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically