Skip to content
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

Deployment to multiple hosts with different ports #85

Closed
saippuakauppias opened this issue Oct 6, 2020 · 6 comments · Fixed by #94
Closed

Deployment to multiple hosts with different ports #85

saippuakauppias opened this issue Oct 6, 2020 · 6 comments · Fixed by #94
Assignees
Labels
enhancement New feature or request

Comments

@saippuakauppias
Copy link

saippuakauppias commented Oct 6, 2020

We send the same release to several servers, but for security we use different ports.
Unfortunately, the current implementation does not provide an option to specify a port in the host field - github action falls with an error: dial tcp: lookup some.hostname.com:6123: no such host

Could you please add such functionality so that we do not duplicate the same code to send the release several times (4 times in our case)?

It would be great if it worked like this:

  - name: multiple host
    uses: appleboy/ssh-action@master
    with:
     host: "foo.com:1234,bar.com,baz:4321"
      username: ${{ secrets.USERNAME }}
      key: ${{ secrets.KEY }}
      port: ${{ secrets.PORT }}
      script: |
        whoami
        ls -al

Let the default port be specified as port 22 or the one that stands in the "port" field, but if the host has its own, you should use it.

Thank you very much!

@appleboy
Copy link
Owner

appleboy commented Oct 8, 2020

Try to set up multiple sections like as below:

  - name: A host
    uses: appleboy/ssh-action@master
    with:
     host: "foo.com"
      username: ${{ secrets.USERNAME }}
      key: ${{ secrets.KEY }}
      port: 1234
      script: |
        whoami
        ls -al
  - name: B host
    uses: appleboy/ssh-action@master
    with:
     host: "bar.com"
      username: ${{ secrets.USERNAME }}
      key: ${{ secrets.KEY }}
      port: 22
      script: |
        whoami
        ls -al

run parallel

@saippuakauppias
Copy link
Author

Yes, that's what we're doing now, but it's not convenient - we have 4 hosts and their number will certainly increase. And the number of lines in the "script" field is more than 10.

Maybe we should add the option described above? Or is there some difficulty?

@appleboy
Copy link
Owner

@saippuakauppias I will take it.

@appleboy appleboy added the enhancement New feature or request label Oct 10, 2020
@appleboy appleboy self-assigned this Oct 10, 2020
appleboy added a commit that referenced this issue Nov 17, 2020
#85

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@appleboy
Copy link
Owner

appleboy commented Nov 17, 2020

@saippuakauppias

Multiple Hosts with different port

  - name: multiple host
    uses: appleboy/ssh-action@master
    with:
-     host: "foo.com"
+     host: "foo.com:1234,bar.com:5678"
      username: ${{ secrets.USERNAME }}
      key: ${{ secrets.KEY }}
      script: |
        whoami
        ls -al

@saippuakauppias
Copy link
Author

@appleboy, I feel like it's not working... Githab action stuck and worked for 6 hours (!!!).

Runtime log (stuck on a server with non-standard port):

our.server.com:3242: ======CMD======
our.server.com:3242: # first deploy
if [ ! -d /home/user/repo ]; then ssh-keyscan github.com >> /home/user/.ssh/known_hosts; cd /home/user/; git clone git_server/repo.git; fi
if [ ! -d /home/user/repo-venv ]; then python3 -m venv /home/user/repo-venv; fi
# checkout to a new release
cd /home/user/repo; git fetch;
cd /home/user/repo; git checkout -q "${GITREF##*/}";
# some another commands

our.server.com:3242: ======END======
Error: The operation was canceled.

This was not the first deploy, directories /home/user/repo and /home/user/repo-venv exist on the server.

@saippuakauppias
Copy link
Author

I forgot to change the version, so it didn't work the first time, and now it's OK.
Thank you for this upgrade!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants