fix: replace bash-isms with sh-compatible syntax and add local-bootstrap existence check
This commit is contained in:
parent
8bbaa456d3
commit
e0a23e1597
|
|
@ -149,19 +149,19 @@ jobs:
|
||||||
|
|
||||||
workspace_dir="${PWD}"
|
workspace_dir="${PWD}"
|
||||||
deploy_dir="${HOMELAB_DEPLOY_DIR:-}"
|
deploy_dir="${HOMELAB_DEPLOY_DIR:-}"
|
||||||
if [[ -z "${deploy_dir}" ]]; then
|
if [ -z "${deploy_dir}" ]; then
|
||||||
for candidate in /home/jv/my-homelab-configs /home/jv/repos/my-homelab-configs "${workspace_dir}"; do
|
for candidate in /home/jv/my-homelab-configs /home/jv/repos/my-homelab-configs "${workspace_dir}"; do
|
||||||
if [[ -d "${candidate}/.git" ]]; then
|
if [ -d "${candidate}/.git" ]; then
|
||||||
deploy_dir="${candidate}"
|
deploy_dir="${candidate}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [[ ! -d "${deploy_dir}/.git" ]]; then
|
if [ ! -d "${deploy_dir}/.git" ]; then
|
||||||
echo "Deploy checkout ${deploy_dir} is not a Git repository." >&2
|
echo "Deploy checkout ${deploy_dir} is not a Git repository." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ "${deploy_dir}" != "${workspace_dir}" ]]; then
|
if [ "${deploy_dir}" != "${workspace_dir}" ]; then
|
||||||
echo "Persistent deploy checkout: ${deploy_dir}"
|
echo "Persistent deploy checkout: ${deploy_dir}"
|
||||||
git -C "${deploy_dir}" fetch "${workspace_dir}" HEAD
|
git -C "${deploy_dir}" fetch "${workspace_dir}" HEAD
|
||||||
git -C "${deploy_dir}" checkout -B main FETCH_HEAD
|
git -C "${deploy_dir}" checkout -B main FETCH_HEAD
|
||||||
|
|
@ -172,24 +172,27 @@ jobs:
|
||||||
git -C "${deploy_dir}" reset --hard HEAD
|
git -C "${deploy_dir}" reset --hard HEAD
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if git -C "${deploy_dir}" remote get-url local-bootstrap >/dev/null 2>&1; then
|
# Set up local-bootstrap remote if the directory exists
|
||||||
git -C "${deploy_dir}" remote set-url local-bootstrap /home/jv/git-server/my-homelab-configs.git
|
if [ -d "/home/jv/git-server/my-homelab-configs.git" ]; then
|
||||||
else
|
if git -C "${deploy_dir}" remote get-url local-bootstrap >/dev/null 2>&1; then
|
||||||
git -C "${deploy_dir}" remote add local-bootstrap /home/jv/git-server/my-homelab-configs.git
|
git -C "${deploy_dir}" remote set-url local-bootstrap /home/jv/git-server/my-homelab-configs.git
|
||||||
|
else
|
||||||
|
git -C "${deploy_dir}" remote add local-bootstrap /home/jv/git-server/my-homelab-configs.git
|
||||||
|
fi
|
||||||
|
git -C "${deploy_dir}" push local-bootstrap HEAD:main
|
||||||
fi
|
fi
|
||||||
git -C "${deploy_dir}" push local-bootstrap HEAD:main
|
|
||||||
|
|
||||||
kubeconfig_probe="${KUBECONFIG_PATH:-${TF_VAR_kubeconfig_path:-${HOME}/.kube/config}}"
|
kubeconfig_probe="${KUBECONFIG_PATH:-${TF_VAR_kubeconfig_path:-${HOME}/.kube/config}}"
|
||||||
action_command="${HOMELAB_ACTION_COMMAND:-auto}"
|
action_command="${HOMELAB_ACTION_COMMAND:-auto}"
|
||||||
if [[ "${action_command}" == "auto" ]]; then
|
if [ "${action_command}" = "auto" ]; then
|
||||||
if [[ -s "${kubeconfig_probe}" ]]; then
|
if [ -s "${kubeconfig_probe}" ]; then
|
||||||
set +e
|
set +e
|
||||||
version_report="$("${deploy_dir}/jeannie" doctor-versions 2>&1)"
|
version_report="$("${deploy_dir}/jeannie" doctor-versions 2>&1)"
|
||||||
version_status=$?
|
version_status=$?
|
||||||
set -e
|
set -e
|
||||||
printf '%s\n' "${version_report}"
|
printf '%s\n' "${version_report}"
|
||||||
|
|
||||||
if ((version_status == 0)); then
|
if [ "${version_status}" -eq 0 ]; then
|
||||||
action_command="apps"
|
action_command="apps"
|
||||||
elif printf '%s\n' "${version_report}" | grep -Eq 'Kubernetes kubelet minors are mixed|At least one kubelet does not match'; then
|
elif printf '%s\n' "${version_report}" | grep -Eq 'Kubernetes kubelet minors are mixed|At least one kubelet does not match'; then
|
||||||
echo "Kubernetes node version drift detected; switching automatic deploy to rebuild-cluster."
|
echo "Kubernetes node version drift detected; switching automatic deploy to rebuild-cluster."
|
||||||
|
|
@ -209,7 +212,7 @@ jobs:
|
||||||
"${deploy_dir}/jeannie" "${action_command}"
|
"${deploy_dir}/jeannie" "${action_command}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported HOMELAB_ACTION_COMMAND: ${action_command}"
|
echo "Unsupported HOMELAB_ACTION_COMMAND: ${action_command}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue