/
action.yaml
50 lines (47 loc) · 1.41 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: "run command ssh"
description: "Run a command over ssh"
inputs:
COMMAND:
description: "the command to run"
required: true
NODE:
description: "the node where to run the command"
required: false
default: "bootstrap"
CAPTURE_RESULT:
description: "whether or not to capture command output, if defined will set a RESULT step output"
required: false
default: "false"
SSH_OPTIONS:
description: "Additional args passed to ssh"
required: false
default: ""
runs:
using: "composite"
steps:
- name: "check ssh_config file"
shell: bash
run: test -f ssh_config
- name: "run command"
shell: bash
if: inputs.CAPTURE_RESULT != 'false'
run: |
echo "RESULT<<EOF" >> $GITHUB_ENV
ssh -F ssh_config ${{ inputs.SSH_OPTIONS }} ${{ inputs.NODE }} "${{ inputs.COMMAND }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Set command output
uses: actions/github-script@v6
if: inputs.CAPTURE_RESULT != 'false'
id: command
with:
script: |
core.setOutput("commandoutput", `${{ env.RESULT }}`);
- name: "run command"
shell: bash
if: inputs.CAPTURE_RESULT == 'false'
run: |
ssh -F ssh_config ${{ inputs.SSH_OPTIONS }} ${{ inputs.NODE }} "${{ inputs.COMMAND }}"
outputs:
RESULT:
description: "the command result"
value: ${{ steps.command.outputs.commandoutput }}