7
7
required : false
8
8
default : " --archive --compress"
9
9
path :
10
- description : Local source directory (always copies its content)
10
+ description : Local source directory (always copies its content only )
11
11
required : true
12
12
remote_path :
13
13
description : Remote destination directory
@@ -25,46 +25,28 @@ inputs:
25
25
remote_key :
26
26
description : SSH private key (OpenSSH/PEM)
27
27
required : true
28
- known_hosts :
29
- description : Optional known_hosts entry for the remote host
30
- required : false
31
28
runs :
32
29
using : composite
33
30
steps :
34
- - name : Prepare SSH
31
+ - name : rsync via ssh-agent
35
32
shell : bash
36
33
run : |
37
34
set -euo pipefail
38
- install -m 700 -d ~/.ssh
39
- printf '%s\n' "${{ inputs.remote_key }}" > ~/.ssh/id_ed25519
40
- chmod 600 ~/.ssh/id_ed25519
41
-
42
- SSH_PORT="${{ inputs.remote_port }}"
43
- [[ -z "$SSH_PORT" ]] && SSH_PORT=22
44
35
45
- if [[ -n "${{ inputs.known_hosts }}" ]]; then
46
- printf '%s\n' "${{ inputs.known_hosts }}" > ~/.ssh/known_hosts
47
- else
48
- ssh-keyscan -p "$SSH_PORT" -H "${{ inputs.remote_host }}" >> ~/.ssh/known_hosts
49
- fi
36
+ # Start agent and load the key
37
+ eval "$(ssh-agent -s)"
38
+ ssh-add - <<< "${{ inputs.remote_key }}"
50
39
51
- - name : Rsync upload
52
- shell : bash
53
- run : |
54
- set -euo pipefail
55
- SSH_PORT="${{ inputs.remote_port }}"
56
- [[ -z "$SSH_PORT" ]] && SSH_PORT=22
57
- SSH_CMD="ssh -p ${SSH_PORT} -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes"
40
+ # SSH command with host key checking disabled (matches your reference impl)
41
+ RSH="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${{ inputs.remote_port }}"
58
42
59
- SRC="${{ inputs.path }}"
43
+ # Resolve paths and DSN
44
+ LOCAL_PATH="${GITHUB_WORKSPACE}/${{ inputs.path }}"
60
45
DEST="${{ inputs.remote_path }}"
61
- USER="${{ inputs.remote_user }}"
62
- HOST="${{ inputs.remote_host }}"
46
+ DSN="${{ inputs.remote_user }}@${{ inputs.remote_host }}"
63
47
64
- # Ensure destination directory exists
65
- ${SSH_CMD} "${USER}@${HOST} " "mkdir -p '${DEST%/}'"
48
+ # Deploy (copy *contents* of LOCAL_PATH into DEST)
49
+ rsync ${{ inputs.switches }} -e "$RSH" "${LOCAL_PATH%/}/ " "$DSN: '${DEST%/}/ '"
66
50
67
- # Copy *contents* of SRC into DEST
68
- rsync ${{ inputs.switches }} \
69
- -e "${SSH_CMD}" \
70
- "${SRC%/}/" "${USER}@${HOST}:'${DEST%/}/'"
51
+ # Cleanup identities from the agent
52
+ ssh-add -D || true
0 commit comments