generated from actions/container-action
-
Notifications
You must be signed in to change notification settings - Fork 20
/
with_key.sh
38 lines (33 loc) · 1.16 KB
/
with_key.sh
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
#!/bin/sh
echo "🔑 Adding ssh key..." &&
eval $(ssh-agent -s) &&
ssh-add <(echo "${INPUT_KEY}") &&
echo "🔐 Added ssh key";
PRE_UPLOAD=${INPUT_PRE_UPLOAD}
if [ ! -z "$PRE_UPLOAD" ]; then
{
echo "👌 Executing pre-upload script..." &&
ssh ${INPUT_SSH_OPTIONS} -p "${INPUT_PORT}" ${INPUT_USER}@${INPUT_HOST} "$INPUT_PRE_UPLOAD && exit" &&
echo "✅ Executed pre-upload script"
} || {
echo "😢 Something went wrong during pre-upload script" && exit 1
}
fi
{
echo "🚚 Uploading via scp..." &&
scp ${INPUT_SSH_OPTIONS} ${INPUT_SCP_OPTIONS} -P "${INPUT_PORT}" -r ${INPUT_LOCAL} ${INPUT_USER}@${INPUT_HOST}:"${INPUT_REMOTE}" &&
echo "🙌 Uploaded via scp"
} || {
echo "😢 Something went wrong during upload" && exit 1
}
POST_UPLOAD=${INPUT_POST_UPLOAD}
if [ ! -z "$POST_UPLOAD" ]; then
{
echo "👌 Executing post-upload script..." &&
ssh ${INPUT_SSH_OPTIONS} -p "${INPUT_PORT}" ${INPUT_USER}@${INPUT_HOST} "$POST_UPLOAD && exit" &&
echo "✅ Executed post-upload script"
} || {
echo "😢 Something went wrong during post-upload script" && exit 1
}
fi
echo "🎉 Done";