-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·33 lines (27 loc) · 900 Bytes
/
Copy pathdeploy.sh
File metadata and controls
executable file
·33 lines (27 loc) · 900 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
: "${DEPLOY_HOST:?DEPLOY_HOST is required}"
: "${DEPLOY_PATH:?DEPLOY_PATH is required}"
deploy_port="${DEPLOY_PORT:-22}"
ssh_options=(-p "${deploy_port}" -o StrictHostKeyChecking=accept-new)
scp_options=(-P "${deploy_port}" -o StrictHostKeyChecking=accept-new)
ssh_cmd=(ssh "${ssh_options[@]}")
scp_cmd=(scp "${scp_options[@]}")
if [[ -n "${SERVER_PASSWORD:-}" ]]; then
if ! command -v sshpass >/dev/null 2>&1; then
echo "sshpass is required when SERVER_PASSWORD is set." >&2
exit 1
fi
export SSHPASS="${SERVER_PASSWORD}"
ssh_cmd=(sshpass -e "${ssh_cmd[@]}")
scp_cmd=(sshpass -e "${scp_cmd[@]}")
fi
remote_path="$(printf '%q' "${DEPLOY_PATH}")"
"${scp_cmd[@]}" ./dist.zip "${DEPLOY_HOST}:${DEPLOY_PATH}/dist.zip"
"${ssh_cmd[@]}" "${DEPLOY_HOST}" << EOF
set -e
cd ${remote_path}
rm -rf cn en
unzip -o dist.zip
rm -f dist.zip
EOF