Skip to content

Commit caebc67

Browse files
committed
Update
1 parent 010ea2e commit caebc67

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

.github/workflows/test.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ jobs:
2828
# cat "${GITHUB_EVENT_PATH}"
2929

3030
- name: "Write YAML Basic"
31-
if: ${{ !github.event.act }}
31+
if: ${{ always() && !github.event.act }}
3232
uses: teunmooij/yaml@v1
3333
with:
3434
data: '{"version":"3.8","services":{"alpine":{"image":"alpine:latest","command":"tail -f /dev/null"}}}'
3535
to-file: "docker-compose.yaml"
3636

3737
- name: "Test SSH Key"
38-
if: ${{ !github.event.act }}
38+
if: ${{ always() && !github.event.act }}
3939
id: test1
4040
uses: ./
4141
with:
@@ -48,12 +48,14 @@ jobs:
4848
ssh_key: "${{ secrets.DOCKER_SSH_KEY }}"
4949

5050
- name: "Write YAML Private"
51+
if: ${{ always() }}
5152
uses: teunmooij/yaml@v1
5253
with:
5354
data: '{"version":"3.8","services":{"alpine":{"image":"${{ env.PRIVATE_IMAGE }}","command":"tail -f /dev/null"}}}'
5455
to-file: "docker-compose.yaml"
5556

5657
- name: "Test Password w/ Registry"
58+
if: ${{ always() }}
5759
id: test2
5860
uses: ./
5961
with:

src/main.sh

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,33 @@ function cleanup_trap() {
1919
exit "${_ST}"
2020
}
2121

22+
SSH_DIR="/root/.ssh"
23+
2224
echo "::group::Starting Stack Deploy Action"
2325
echo "User: $(whoami)"
2426
echo "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"
2933
echo "::endgroup::"
3034

3135
if [ -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}"
4043
else
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"
4649
fi
4750
echo "::endgroup::"
4851

@@ -83,11 +86,13 @@ if [[ -n "${INPUT_REGISTRY_AUTH}" ]];then
8386
fi
8487
# shellcheck disable=SC2034
8588
STACK_RESULTS=$(docker stack deploy -c "${INPUT_FILE}" "${INPUT_NAME}" "${EXTRA_ARGS[@]}")
86-
echo "${STACK_RESULTS}"
8789
echo "::endgroup::"
8890

91+
echo "${STACK_RESULTS}"
92+
8993
if [[ "${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!"
9398
fi

0 commit comments

Comments
 (0)