-
-
Notifications
You must be signed in to change notification settings - Fork 545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiline SSH commands interpreted as single lines #75
Comments
Example: script: |
echo $(ls) # Will echo the Runner directory and probable raise an error somewhere
echo \$(ls) # Will echo the remote directory If you want multiline command you should escaping the script: |
ls \\
-lah |
Ah! Of everything I tried, I never thought to escape the backslash. I'll give that a go. Thanks @KerberosMorphy! |
Interestingly, @KerberosMorphy, I've just tried the multiline ls command and it's not worked.
This is using ETA: Same issue with |
I've tried blank lines, |
Sorry, my bad, I had adapted this action to work with Bitbucket/GitLab/GitHub. When talking to you I was testing on bitbucket and it's works there. For GitHub I use directly: jobs:
ssh_job:
runs-on: ubuntu-latest
steps:
- uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
passphrase: ${{ secrets.PASSPHRASE }}
key: ${{ secrets.KEY }}
script: |
ls \
-lah And it's working. ======CMD======
ls \
-lah
======END======
out: total 36K
out: drwxr-xr-x 5 user user 4.0K Apr 14 18:58 .
out: drwxr-xr-x 31 root root 4.0K Jul 28 15:18 ..
out: -rw-r--r-- 1 user user 220 Aug 31 2015 .bash_logout
out: -rw-r--r-- 1 user user 3.7K Aug 31 2015 .bashrc
out: drwx------ 3 user user 4.0K Apr 14 19:09 .cache
out: -rw-r--r-- 1 user user 655 Jun 24 2016 .profile
out: drwx------ 2 user user 4.0K Apr 14 13:23 .ssh
out: drwxrwxr-x 5 user user 4.0K Apr 14 18:58 .vscode-server
out: -rw-rw-r-- 1 user user 185 Apr 14 18:59 .wget-hsts
==============================================
✅ Successfully executed commands to all host.
============================================== |
It also works for me. See https://github.com/appleboy/ssh-action/runs/940852614?check_suite_focus=true |
How bizarre! Good news though, means I'm the problem, and that's something I can solve. Thanks both, I'll get back to testing, see if I can't work out specifically what is causing this. |
@adamkdean If you find out tell us. Also I think you can close this issue if solve. |
Hi sorry folks, I found the issue but was waylaid mid-typing. Looks like the culprit is Sorry I can't investigate further at the moment, I'll be available for more testing tomorrow (UK based here.) Thanks again for the support (and of course the fantastic library!) |
@adamkdean Thanks for your report. You use the script_stop: true
script: |
docker stop example
docker rm example
docker run \
--detach \
--restart always \
--publish 80:80 \
--publish 443:443 \
--name example \
--network example-network \
--volume example-volume:/var/example/volume \
example/image-name |
@appleboy That's right, with the above being a simple example showing where the multiple lines would be useful. |
I will bump the new version to fix the issue. |
@adamkdean Please try the https://github.com/appleboy/ssh-action/releases/tag/v0.1.3 version |
Works perfectly. Thanks dude. 👏 |
can u provide adapted for gitlab-ci action example? |
@fankins Do you mean https://github.com/appleboy/gitlab-ci-action ? |
@fankins, you can migrate almost any GitHub action to GitLab CI or Bitbucket Pipeline if it's base on a Docker. I got some trouble with this action with GitLab CI, I don't remember if it as finally work. I choose to create my own cause I needed to pass some additional flags to forward agent, but I wrote a little explanation of how to Convert GitHub Action. |
hey @KerberosMorphy I see you mentionned using this project in a Gitlab pipeline (if I have not misunderstood). Would you be so kind to tell me if it is any different than for GitHub? If possible, I'd be happy to see your pipeline's file 😄 |
@HunteRoi, this is quite old, I don't have the code inside the specific pipeline, but I have my old version of this action. I made a gist with my alternative of appleboy ssh-commands-action. If it can be useful to you or anyone: https://gist.github.com/KerberosMorphy/40ad61bdf5de3943a1bca4567b186d44 |
There may be a simple solution to this but so far I've been unable to find it.
The follow script has three commands:
docker stop
,docker rm
, anddocker run
. Unfortunately, the backslash\
at the end ofdocker run
is ignored, and so each of the params that follow are interpreted as their own commands.While all of this could fit on one line, it'll make more complex workflows unreadable and harder to maintain.
The text was updated successfully, but these errors were encountered: