name: SSH runner description: run commands on SSH hosts inputs: host: description: SSH host required: true user: description: SSH user required: true key: description: SSH private key required: true script: description: commands to run via SSH required: true port: description: SSH port required: false default: "22" runs: using: "composite" steps: - name: setup ssh shell: bash env: SSH_KEY: ${{ inputs.key }} HOST: ${{ inputs.host }} PORT: ${{ inputs.port }} run: | set -euo pipefail mkdir -p ~/.ssh printf '%s\n' "$SSH_KEY" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 ssh-keyscan -p "$PORT" -H "$HOST" >> ~/.ssh/known_hosts chmod 600 ~/.ssh/known_hosts - name: run on docker host shell: bash env: HOST: ${{ inputs.host }} USER: ${{ inputs.user }} PORT: ${{ inputs.port }} SCRIPT: ${{ inputs.script }} run: | set -euo pipefail ssh -p "$PORT" "$USER@$HOST" bash -s <<< "$SCRIPT"