7 Commits

4 changed files with 43 additions and 16 deletions

View File

@ -6,8 +6,11 @@ jobs:
name: Build name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout
uses: actions/checkout@v1
- name: executing remote ssh commands using password - name: executing remote ssh commands using password
uses: appleboy/ssh-action@master uses: ./
with: with:
host: ${{ secrets.HOST }} host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }} username: ${{ secrets.USERNAME }}
@ -16,7 +19,7 @@ jobs:
script: whoami script: whoami
- name: executing remote ssh commands using ssh key - name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master uses: ./
with: with:
host: ${{ secrets.HOST }} host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }} username: ${{ secrets.USERNAME }}
@ -25,7 +28,7 @@ jobs:
script: whoami script: whoami
- name: multiple command - name: multiple command
uses: appleboy/ssh-action@master uses: ./
with: with:
host: ${{ secrets.HOST }} host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }} username: ${{ secrets.USERNAME }}
@ -36,7 +39,7 @@ jobs:
ls -al ls -al
# - name: stop script if command error # - name: stop script if command error
# uses: appleboy/ssh-action@master # uses: ./
# with: # with:
# host: ${{ secrets.HOST }} # host: ${{ secrets.HOST }}
# username: ${{ secrets.USERNAME }} # username: ${{ secrets.USERNAME }}
@ -48,7 +51,7 @@ jobs:
# ls -al # ls -al
- name: pass environment - name: pass environment
uses: appleboy/ssh-action@master uses: ./
env: env:
FOO: "BAR" FOO: "BAR"
with: with:
@ -62,22 +65,24 @@ jobs:
echo "I am $BAR, thanks" echo "I am $BAR, thanks"
- name: pass multiple environment - name: pass multiple environment
uses: appleboy/ssh-action@master uses: ./
env: env:
FOO: "BAR" FOO: "BAR"
BAR: "FOO" BAR: "FOO"
SHA: ${{ github.sha }}
with: with:
host: ${{ secrets.HOST }} host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }} username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }} key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }} port: ${{ secrets.PORT }}
envs: FOO,BAR envs: FOO,BAR,SHA
script: | script: |
echo "I am $FOO, thanks" echo "I am $FOO, thanks"
echo "I am $BAR, thanks" echo "I am $BAR, thanks"
echo "sha: $SHA"
- name: ssh key passphrase - name: ssh key passphrase
uses: appleboy/ssh-action@master uses: ./
with: with:
host: ${{ secrets.HOST }} host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }} username: ${{ secrets.USERNAME }}

View File

@ -1,4 +1,4 @@
FROM appleboy/drone-ssh:1.5.5-linux-amd64 FROM appleboy/drone-ssh:1.5.6-linux-amd64
ADD entrypoint.sh /entrypoint.sh ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh

View File

@ -45,11 +45,12 @@ out: ***
See [action.yml](./action.yml) for more detailed information. See [action.yml](./action.yml) for more detailed information.
* host - remote host * host - ssh host
* port - remote port, default is `22` * port - ssh port, default is `22`
* username - ssh username * username - ssh username
* password - ssh password * password - ssh password
* passphrase - the passphrase is usually to encrypt the private key * passphrase - the passphrase is usually to encrypt the private key
* sync - synchronous execution if multiple hosts, default is false
* timeout - timeout for ssh to remote host, default is `30s` * timeout - timeout for ssh to remote host, default is `30s`
* command_timeout - timeout for ssh command, default is `10m` * command_timeout - timeout for ssh command, default is `10m`
* key - content of ssh private key. ex raw content of ~/.ssh/id_rsa * key - content of ssh private key. ex raw content of ~/.ssh/id_rsa
@ -131,6 +132,22 @@ Multiple Hosts
ls -al ls -al
``` ```
Synchronous execution on multiple hosts
```diff
- name: multiple host
uses: appleboy/ssh-action@master
with:
host: "foo.com,bar.com"
+ sync: true
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
whoami
ls -al
```
Pass environment variable to shell script Pass environment variable to shell script
```diff ```diff
@ -139,6 +156,7 @@ Pass environment variable to shell script
+ env: + env:
+ FOO: "BAR" + FOO: "BAR"
+ BAR: "FOO" + BAR: "FOO"
+ SHA: ${{ github.sha }}
with: with:
host: ${{ secrets.HOST }} host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }} username: ${{ secrets.USERNAME }}
@ -148,6 +166,7 @@ Pass environment variable to shell script
script: | script: |
echo "I am $FOO" echo "I am $FOO"
echo "I am $BAR" echo "I am $BAR"
echo "sha: $SHA"
``` ```
Stop script after first failure. ex: missing `abc` folder Stop script after first failure. ex: missing `abc` folder

View File

@ -3,9 +3,9 @@ description: 'Executing remote ssh commands'
author: 'Bo-Yi Wu' author: 'Bo-Yi Wu'
inputs: inputs:
host: host:
description: 'ssh remote host' description: 'ssh host'
port: port:
description: 'ssh remote port' description: 'ssh port'
default: 22 default: 22
passphrase: passphrase:
description: 'ssh key passphrase' description: 'ssh key passphrase'
@ -13,8 +13,11 @@ inputs:
description: 'ssh username' description: 'ssh username'
password: password:
description: 'ssh password' description: 'ssh password'
sync:
description: 'synchronous execution if multiple hosts'
default: false
timeout: timeout:
description: 'timeout for ssh to remote host' description: 'timeout for ssh to host'
default: "30s" default: "30s"
command_timeout: command_timeout:
description: 'timeout for ssh command' description: 'timeout for ssh command'
@ -24,9 +27,9 @@ inputs:
key_path: key_path:
description: 'path of ssh private key' description: 'path of ssh private key'
proxy_host: proxy_host:
description: 'ssh proxy remote host' description: 'ssh proxy host'
proxy_port: proxy_port:
description: 'ssh proxy remote port' description: 'ssh proxy port'
default: 22 default: 22
proxy_username: proxy_username:
description: 'ssh proxy username' description: 'ssh proxy username'