scp-action/action.yml
Bo-Yi Wu 98b7132065
feat: migrate to composite action with dynamic drone-scp support (#197)
- Remove Dockerfile and switch the action implementation from Docker to composite actions
- Add support for specifying the drone-scp version and automatically download the appropriate binary at runtime
- Add new inputs: curl_insecure, capture_stdout, and version for improved flexibility and output handling
- Add output for capturing standard output from executed commands when enabled
- entrypoint.sh refactored from sh to bash and made more robust with error handling, dynamic platform/architecture detection, and secure downloading of the binary
- Action now works cross-platform rather than being tied to a specific Docker image

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2025-04-27 10:38:00 +08:00

143 lines
5.1 KiB
YAML

name: "SCP Command to Transfer Files"
description: "How to Use SCP Command to Transfer Files/Folders in Linux"
author: "Bo-Yi Wu"
inputs:
host:
description: "scp remote host"
port:
description: "scp remote port"
default: "22"
username:
description: "scp username"
password:
description: "scp password"
protocol:
description: "The IP protocol to use. Valid values are 'tcp'. 'tcp4' or 'tcp6'. Default to tcp."
default: "tcp"
timeout:
description: "timeout for ssh to remote host"
default: "30s"
command_timeout:
description: "timeout for scp command"
default: "10m"
key:
description: "content of ssh private key. ex raw content of ~/.ssh/id_rsa"
key_path:
description: "path of ssh private key"
passphrase:
description: "ssh key passphrase"
fingerprint:
description: "fingerprint SHA256 of the host public key, default is to skip verification"
use_insecure_cipher:
description: "include more ciphers with use_insecure_cipher"
target:
description: "target path on the server, must be a directory path."
source:
description: "scp file list"
rm:
description: "remove target folder before upload data"
debug:
description: "enable debug message"
strip_components:
description: "remove the specified number of leading path elements"
overwrite:
description: "use --overwrite flag with tar"
tar_dereference:
description: "use --dereference flag with tar"
tar_tmp_path:
description: "temporary path for tar file on the dest host"
tar_exec:
description: "temporary path for tar file on the dest host"
default: "tar"
proxy_host:
description: "ssh proxy remote host"
proxy_port:
description: "ssh proxy remote port"
default: "22"
proxy_username:
description: "ssh proxy username"
proxy_password:
description: "ssh proxy password"
proxy_passphrase:
description: "ssh proxy key passphrase"
proxy_timeout:
description: "timeout for ssh to proxy host"
default: "30s"
proxy_key:
description: "content of ssh proxy private key. ex raw content of ~/.ssh/id_rsa"
proxy_key_path:
description: "path of ssh proxy private key"
proxy_fingerprint:
description: "fingerprint SHA256 of the host public key, default is to skip verification"
proxy_use_insecure_cipher:
description: "include more ciphers with use_insecure_cipher"
curl_insecure:
description: "When true, uses the --insecure option with curl for insecure downloads."
default: "false"
capture_stdout:
description: "When true, captures and returns standard output from the commands as action output."
default: "false"
version:
description: |
The version of drone-scp to use.
outputs:
stdout:
description: "Standard output of the executed commands when capture_stdout is enabled."
value: ${{ steps.entrypoint.outputs.stdout }}
runs:
using: "composite"
steps:
- name: Set GitHub Path
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
- id: entrypoint
name: Run entrypoint.sh
run: entrypoint.sh
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
INPUT_HOST: ${{ inputs.host }}
INPUT_PORT: ${{ inputs.port }}
INPUT_PROTOCOL: ${{ inputs.protocol }}
INPUT_USERNAME: ${{ inputs.username }}
INPUT_PASSWORD: ${{ inputs.password }}
INPUT_PASSPHRASE: ${{ inputs.passphrase }}
INPUT_KEY: ${{ inputs.key }}
INPUT_KEY_PATH: ${{ inputs.key_path }}
INPUT_FINGERPRINT: ${{ inputs.fingerprint }}
INPUT_PROXY_HOST: ${{ inputs.proxy_host }}
INPUT_PROXY_PORT: ${{ inputs.proxy_port }}
INPUT_PROXY_USERNAME: ${{ inputs.proxy_username }}
INPUT_PROXY_PASSWORD: ${{ inputs.proxy_password }}
INPUT_PROXY_PASSPHRASE: ${{ inputs.proxy_passphrase }}
INPUT_PROXY_KEY: ${{ inputs.proxy_key }}
INPUT_PROXY_KEY_PATH: ${{ inputs.proxy_key_path }}
INPUT_PROXY_FINGERPRINT: ${{ inputs.proxy_fingerprint }}
INPUT_USE_INSECURE_CIPHER: ${{ inputs.use_insecure_cipher }}
INPUT_CIPHER: ${{ inputs.cipher }}
INPUT_PROXY_USE_INSECURE_CIPHER: ${{ inputs.proxy_use_insecure_cipher }}
INPUT_PROXY_CIPHER: ${{ inputs.proxy_cipher }}
INPUT_DEBUG: ${{ inputs.debug }}
INPUT_TIMEOUT: ${{ inputs.timeout }}
INPUT_COMMAND_TIMEOUT: ${{ inputs.command_timeout }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_SOURCE: ${{ inputs.source }}
INPUT_RM: ${{ inputs.rm }}
INPUT_STRIP_COMPONENTS: ${{ inputs.strip_components }}
INPUT_OVERWRITE: ${{ inputs.overwrite }}
INPUT_TAR_DEREFERENCE: ${{ inputs.tar_dereference }}
INPUT_TAR_TMP_PATH: ${{ inputs.tar_tmp_path }}
INPUT_TAR_EXEC: ${{ inputs.tar_exec }}
INPUT_PROXY_TIMEOUT: ${{ inputs.proxy_timeout }}
INPUT_CAPTURE_STDOUT: ${{ inputs.capture_stdout }}
INPUT_CURL_INSECURE: ${{ inputs.curl_insecure }}
DRONE_SCP_VERSION: ${{ inputs.version }}
branding:
icon: "copy"
color: "gray-dark"