Skip to content

Commit 362a7f1

Browse files
chore: support running commands from a file (#341)
1 parent ab698e5 commit 362a7f1

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ jobs:
4242
set -e
4343
whoami
4444
45+
- name: ssh commands from a file
46+
uses: ./
47+
with:
48+
host: ${{ env.REMOTE_HOST }}
49+
username: linuxserver.io
50+
password: password
51+
port: 2222
52+
script_path: testdata/test.sh
53+
4554
check-ssh-key:
4655
runs-on: ubuntu-latest
4756
steps:

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ See [action.yml](./action.yml) for more detailed information.
4646
| proxy_cipher | Allowed cipher algorithms for the proxy | |
4747
| proxy_use_insecure_cipher | Include more ciphers with use_insecure_cipher for the proxy | false |
4848
| script | Execute commands | |
49+
| script_file | Execute commands from a file | |
4950
| script_stop | Stop script after first failure | false |
5051
| envs | Pass environment variables to shell script | |
5152
| envs_format | Flexible configuration of environment value transfer | |
@@ -222,6 +223,19 @@ ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"
222223
223224
![result](./images/output-result.png)
224225
226+
#### Commands from a file
227+
228+
```yaml
229+
- name: file commands
230+
uses: appleboy/ssh-action@v1.1.0
231+
with:
232+
host: ${{ secrets.HOST }}
233+
username: ${{ secrets.USERNAME }}
234+
key: ${{ secrets.KEY }}
235+
port: ${{ secrets.PORT }}
236+
script_path: scripts/script.sh
237+
```
238+
225239
#### Multiple Hosts
226240
227241
```diff

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ inputs:
6363
description: "Include more ciphers for the proxy by using insecure ciphers."
6464
script:
6565
description: "Commands to be executed."
66+
script_path:
67+
description: "Path to the file containing commands to be executed."
6668
script_stop:
6769
description: "Stop the script after the first failure."
6870
envs:
@@ -110,6 +112,7 @@ runs:
110112
INPUT_PROXY_TIMEOUT: ${{ inputs.proxy_timeout }}
111113
INPUT_COMMAND_TIMEOUT: ${{ inputs.command_timeout }}
112114
INPUT_SCRIPT: ${{ inputs.script }}
115+
INPUT_SCRIPT_FILE: ${{ inputs.script_path }}
113116
INPUT_SCRIPT_STOP: ${{ inputs.script_stop }}
114117
INPUT_ENVS: ${{ inputs.envs }}
115118
INPUT_ENVS_FORMAT: ${{ inputs.envs_format }}

testdata/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
whoami

0 commit comments

Comments
 (0)