-
-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: enhance GitHub Actions for IPv6 and flexibility (#303)
* ci: enhance GitHub Actions for IPv6 and flexibility - Add a new CI job for testing IPv6 in GitHub Actions workflow - Update the Docker image version from `1.7.3` to `1.7.4` - Add a new `protocol` input parameter to the GitHub action with a default value of `tcp` - Change the GitHub action to use a composite run steps action instead of a Docker container - Update the `entrypoint.sh` script to use `bash` instead of `sh`, set stricter error handling, and add a function to detect client platform and architecture - Modify the `entrypoint.sh` script to download a specific version of `drone-ssh` based on the detected client info and execute it Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * ci: refactor CI workflow and Docker setup - Remove IPv6 ping command from CI workflow - Uncomment Docker run configuration in action.yml Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Loading branch information
Showing
4 changed files
with
139 additions
and
6 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
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,66 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
export GITHUB="true" | ||
|
||
sh -c "/bin/drone-ssh $*" | ||
DRONE_SSH_RELEASE_URL="${DRONE_SSH_RELEASE_URL:-https://github.com/appleboy/drone-ssh/releases/download}" | ||
DRONE_SSH_VERSION="${DRONE_SSH_VERSION:-1.7.4}" | ||
|
||
function detect_client_info() { | ||
if [ -n "${SSH_CLIENT_OS-}" ]; then | ||
CLIENT_PLATFORM="${SSH_CLIENT_OS}" | ||
else | ||
local kernel | ||
kernel="$(uname -s)" | ||
case "${kernel}" in | ||
Darwin) | ||
CLIENT_PLATFORM="darwin" | ||
;; | ||
Linux) | ||
CLIENT_PLATFORM="linux" | ||
;; | ||
Windows) | ||
CLIENT_PLATFORM="windows" | ||
;; | ||
*) | ||
echo "Unknown, unsupported platform: ${kernel}." >&2 | ||
echo "Supported platforms: Linux, Darwin and Windows." >&2 | ||
echo "Bailing out." >&2 | ||
exit 2 | ||
esac | ||
fi | ||
|
||
if [ -n "${SSH_CLIENT_ARCH-}" ]; then | ||
CLIENT_ARCH="${SSH_CLIENT_ARCH}" | ||
else | ||
# TODO: migrate the kube::util::host_platform function out of hack/lib and | ||
# use it here. | ||
local machine | ||
machine="$(uname -m)" | ||
case "${machine}" in | ||
x86_64*|i?86_64*|amd64*) | ||
CLIENT_ARCH="amd64" | ||
;; | ||
aarch64*|arm64*) | ||
CLIENT_ARCH="arm64" | ||
;; | ||
*) | ||
echo "Unknown, unsupported architecture (${machine})." >&2 | ||
echo "Supported architectures x86_64, i686, arm64." >&2 | ||
echo "Bailing out." >&2 | ||
exit 3 | ||
;; | ||
esac | ||
fi | ||
} | ||
|
||
detect_client_info | ||
DOWNLOAD_URL_PREFIX="${DRONE_SSH_RELEASE_URL}/v${DRONE_SSH_VERSION}" | ||
CLIENT_BINARY="drone-ssh-${DRONE_SSH_VERSION}-${CLIENT_PLATFORM}-${CLIENT_ARCH}" | ||
echo "Will download ${CLIENT_BINARY} from ${DOWNLOAD_URL_PREFIX}" | ||
curl -fL --retry 3 --keepalive-time 2 "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o ${GITHUB_ACTION_PATH}/drone-ssh | ||
chmod +x ${GITHUB_ACTION_PATH}drone-ssh | ||
sh -c "${GITHUB_ACTION_PATH}/drone-ssh $*" |