22
33set -e
44
5- # echo "🏳️ Starting Stack Deploy Action"
6-
75function cleanup_trap() {
86 _ST=" $? "
97 if [[ " ${_ST} " != " 0" ]]; then
10- echo -e " \u001b[31 ;1mScript Exited with Error: ${_ST} "
8+ echo -e " ⚠️ \u001b[33 ;1mScript Exited with Error: ${_ST} "
119 fi
1210 if [ -z " ${INPUT_SSH_KEY} " ]; then
13- echo -e " \u001b[35mCleaning Up authorized_keys on: ${INPUT_HOST} "
11+ echo -e " Cleaning Up authorized_keys on: \u001b[36;1m ${INPUT_HOST} "
1412 ssh -p " ${INPUT_PORT} " " ${INPUT_USER} @${INPUT_HOST} " \
1513 " sed -i '/docker-stack-deploy-action/d' ~/.ssh/authorized_keys"
1614 fi
1715 if [[ " ${_ST} " == " 0" ]]; then
18- echo -e " \u001b[32;1mFinished Success."
16+ echo -e " ✅ \u001b[32;1mFinished Success."
1917 fi
2018 exit " ${_ST} "
2119}
2220
23-
24-
2521echo " ::group::Starting Stack Deploy Action"
2622echo " User: $( whoami) "
2723echo " Script: ${0} "
2824echo " Directory: $( pwd) "
29-
3025mkdir -p /root/.ssh
3126chmod 0700 /root/.ssh
3227ssh-keyscan -p " ${INPUT_PORT} " -H " ${INPUT_HOST} " >> /root/.ssh/known_hosts
33-
3428echo " ::endgroup::"
3529
3630if [ -z " ${INPUT_SSH_KEY} " ]; then
37- echo -e " ::group::\u001b[36mCreating and Copying SSH Key to: ${INPUT_HOST} "
31+ echo -e " ::group::Creating and Copying SSH Key to: \u001b[36;1m ${INPUT_HOST} "
3832 ssh-keygen -q -f /root/.ssh/id_rsa -N " " -C " docker-stack-deploy-action"
3933 eval " $( ssh-agent -s) "
4034 ssh-add /root/.ssh/id_rsa
@@ -43,30 +37,28 @@ if [ -z "${INPUT_SSH_KEY}" ];then
4337 ssh-copy-id -p " ${INPUT_PORT} " -i /root/.ssh/id_rsa \
4438 " ${INPUT_USER} @${INPUT_HOST} "
4539else
46- echo -e " ::group::\u001b[36mAdding SSH Key to SSH Agent"
40+ echo -e " ::group::Adding SSH Key to SSH Agent"
4741 echo " ${INPUT_SSH_KEY} " > /root/.ssh/id_rsa
4842 chmod 0600 /root/.ssh/id_rsa
4943 eval " $( ssh-agent -s) "
5044 ssh-add /root/.ssh/id_rsa
5145fi
52-
5346echo " ::endgroup::"
5447
5548trap cleanup_trap EXIT HUP INT QUIT PIPE TERM
5649
57- echo -e " ::group::\u001b[36mVerifying Docker and Setting Context."
50+ echo -e " ::group::Verifying Docker and Setting Context."
5851ssh -p " ${INPUT_PORT} " " ${INPUT_USER} @${INPUT_HOST} " " docker info" > /dev/null
5952
6053if ! docker context inspect remote > /dev/null 2>&1 ; then
6154 docker context create remote --docker " host=ssh://${INPUT_USER} @${INPUT_HOST} :${INPUT_PORT} "
6255fi
6356docker context use remote
6457docker context ls
65-
6658echo " ::endgroup::"
6759
6860if [ -n " ${INPUT_ENV_FILE} " ]; then
69- echo -e " \u001b[36mSourcing Environment File: \u001b[37 ;1m${INPUT_ENV_FILE} "
61+ echo -e " Sourcing Environment File: \u001b[36 ;1m${INPUT_ENV_FILE} "
7062 stat " ${INPUT_ENV_FILE} "
7163 set -a
7264 # shellcheck disable=SC1090
@@ -76,14 +68,14 @@ if [ -n "${INPUT_ENV_FILE}" ];then
7668fi
7769
7870if [[ -n " ${INPUT_REGISTRY_USER} " && -n " ${INPUT_REGISTRY_PASS} " ]]; then
79- echo -e " ::group::\u001b[36mLogging in to Registry: \u001b[0m ${INPUT_REGISTRY_HOST:- Docker Hub} "
71+ echo -e " ::group::Logging in to Registry: \u001b[36;1m ${INPUT_REGISTRY_HOST:- Docker Hub} "
8072 echo " ${INPUT_REGISTRY_PASS} " |
8173 docker login --username " ${INPUT_REGISTRY_USER} " --password-stdin " ${INPUT_REGISTRY_HOST} "
8274 INPUT_REGISTRY_AUTH=" true"
8375 echo " ::endgroup::"
8476fi
8577
86- echo -e " ::group::\u001b[36mDeploying Stack: \u001b[0m ${INPUT_NAME} "
78+ echo -e " ::group::Deploying Stack: \u001b[36;1m ${INPUT_NAME} "
8779
8880EXTRA_ARGS=()
8981if [[ -n " ${INPUT_REGISTRY_AUTH} " ]]; then
0 commit comments