@@ -19,30 +19,33 @@ function cleanup_trap() {
1919 exit " ${_ST} "
2020}
2121
22+ SSH_DIR=" /root/.ssh"
23+
2224echo " ::group::Starting Stack Deploy Action"
2325echo " User: $( whoami) "
2426echo " Script: ${0} "
25- echo -e " Directory: $( pwd) "
26- mkdir -p /root/.ssh
27- chmod 0700 /root/.ssh
28- ssh-keyscan -p " ${INPUT_PORT} " -H " ${INPUT_HOST} " >> /root/.ssh/known_hosts
27+ echo " Current Directory: $( pwd) "
28+ echo " Home Directory: ${HOME} "
29+ echo " SSH Directory: ${SSH_DIR} "
30+ mkdir -p " ${SSH_DIR} " ~ /.ssh
31+ chmod 0700 " ${SSH_DIR} " ~ /.ssh
32+ ssh-keyscan -p " ${INPUT_PORT} " -H " ${INPUT_HOST} " >> " ${SSH_DIR} /known_hosts"
2933echo " ::endgroup::"
3034
3135if [ -z " ${INPUT_SSH_KEY} " ]; then
3236 echo -e " ::group::Copying SSH Key to Remote Host"
33- ssh-keygen -q -f /root/.ssh/ id_rsa -N " " -C " docker-stack-deploy-action"
37+ ssh-keygen -q -f " ${SSH_DIR} / id_rsa" -N " " -C " docker-stack-deploy-action"
3438 eval " $( ssh-agent -s) "
35- ssh-add /root/.ssh/id_rsa
36- mkdir ~ /.ssh
39+ ssh-add " ${SSH_DIR} /id_rsa"
3740 sshpass -eINPUT_PASS \
38- ssh-copy-id -i /root/.ssh/ id_rsa -o ConnectTimeout=15 \
41+ ssh-copy-id -i " ${SSH_DIR} / id_rsa" -o ConnectTimeout=15 \
3942 -p " ${INPUT_PORT} " " ${INPUT_USER} @${INPUT_HOST} "
4043else
4144 echo " ::group::Adding SSH Key to SSH Agent"
42- echo " ${INPUT_SSH_KEY} " > /root/.ssh/ id_rsa
43- chmod 0600 /root/.ssh/ id_rsa
45+ echo " ${INPUT_SSH_KEY} " > " ${SSH_DIR} / id_rsa"
46+ chmod 0600 " ${SSH_DIR} / id_rsa"
4447 eval " $( ssh-agent -s) "
45- ssh-add /root/.ssh/ id_rsa
48+ ssh-add " ${SSH_DIR} / id_rsa"
4649fi
4750echo " ::endgroup::"
4851
@@ -83,11 +86,13 @@ if [[ -n "${INPUT_REGISTRY_AUTH}" ]];then
8386fi
8487# shellcheck disable=SC2034
8588STACK_RESULTS=$( docker stack deploy -c " ${INPUT_FILE} " " ${INPUT_NAME} " " ${EXTRA_ARGS[@]} " )
86- echo " ${STACK_RESULTS} "
8789echo " ::endgroup::"
8890
91+ echo " ${STACK_RESULTS} "
92+
8993if [[ " ${INPUT_SUMMARY} " == " true" ]]; then
9094 echo " 📝 Writing Job Summary"
9195 # shellcheck source=/src/summary.sh
92- source /src/summary.sh >> " ${GITHUB_STEP_SUMMARY} "
96+ source /src/summary.sh >> " ${GITHUB_STEP_SUMMARY} " || \
97+ echo " ::error::Failed to Write Job Summary!"
9398fi
0 commit comments