-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(workflow): enhance SSH setup and cleanup logic (#11)
- Reorganized the workflow to improve clarity and maintainability: - Added a new `noop.sh` script for setup post-check of known hosts. - Moved the `Setup SSH key` step after `Check known hosts file` for better sequence. - Improved the `check.sh` script: - Validates the presence of expected SSH fingerprints in the `known_hosts` file. - Updated the `post_action.sh` script: - Simplified removal of the `known_hosts` file instead of line-by-line cleanup. - Adjusted `post_check.sh` to ensure the `known_hosts` file is completely removed. - Updated `action.yml` to include corrected paths and a reordering of the steps.
- Loading branch information
Showing
6 changed files
with
34 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
#!/usr/bin/env sh | ||
|
||
if [ ! -s "${HOME}/.ssh/known_hosts" ]; then | ||
SSH_KNOWN_HOSTS_FILE="${HOME}/.ssh/known_hosts" | ||
|
||
if ! grep -q "${SSH_KNOWN_HOSTS}" "${SSH_KNOWN_HOSTS_FILE}"; then | ||
echo "::error file=$(basename "$0"),line=${LINENO},endLine=${LINENO},title=Assertion Error::\ | ||
~/.ssh/known_hosts is missing or empty." | ||
${SSH_KNOWN_HOSTS_FILE} file should contain the ssh fingerprint." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
unset SSH_KNOWN_HOSTS_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env sh | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
#!/usr/bin/env sh | ||
|
||
SSH_KNOWN_HOSTS_FILE="${HOME}/.ssh/known_hosts" | ||
TEMP_FILE="/tmp/718f4157-5493-43b2-837b-3ccb27f78e7b" | ||
|
||
sed '$ d' "${SSH_KNOWN_HOSTS_FILE}" > "${TEMP_FILE}" | ||
cat "${TEMP_FILE}" > "${SSH_KNOWN_HOSTS_FILE}" | ||
rm -rf "${TEMP_FILE}" | ||
rm -rf "${SSH_KNOWN_HOSTS_FILE}" | ||
|
||
echo "::notice file=$(basename "$0"),line=${LINENO},endLine=${LINENO},title=Notice::\ | ||
${SSH_KNOWN_HOSTS_FILE} has been cleaned." | ||
${SSH_KNOWN_HOSTS_FILE} has been removed." | ||
|
||
unset SSH_KNOWN_HOSTS_FILE | ||
unset TEMP_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters