From e0a23e15972d030bb6a760b05b97ec617c32dc2d Mon Sep 17 00:00:00 2001 From: jv Date: Fri, 18 Sep 2026 14:41:47 -0500 Subject: [PATCH] fix: replace bash-isms with sh-compatible syntax and add local-bootstrap existence check --- .gitea/workflows/homelab-main.yml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/homelab-main.yml b/.gitea/workflows/homelab-main.yml index 75f6140..9dd9c2a 100644 --- a/.gitea/workflows/homelab-main.yml +++ b/.gitea/workflows/homelab-main.yml @@ -149,19 +149,19 @@ jobs: workspace_dir="${PWD}" 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 - if [[ -d "${candidate}/.git" ]]; then + if [ -d "${candidate}/.git" ]; then deploy_dir="${candidate}" break fi done fi - if [[ ! -d "${deploy_dir}/.git" ]]; then + if [ ! -d "${deploy_dir}/.git" ]; then echo "Deploy checkout ${deploy_dir} is not a Git repository." >&2 exit 1 fi - if [[ "${deploy_dir}" != "${workspace_dir}" ]]; then + if [ "${deploy_dir}" != "${workspace_dir}" ]; then echo "Persistent deploy checkout: ${deploy_dir}" git -C "${deploy_dir}" fetch "${workspace_dir}" HEAD git -C "${deploy_dir}" checkout -B main FETCH_HEAD @@ -172,24 +172,27 @@ jobs: git -C "${deploy_dir}" reset --hard HEAD fi - if git -C "${deploy_dir}" remote get-url local-bootstrap >/dev/null 2>&1; then - 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 + # Set up local-bootstrap remote if the directory exists + if [ -d "/home/jv/git-server/my-homelab-configs.git" ]; then + if git -C "${deploy_dir}" remote get-url local-bootstrap >/dev/null 2>&1; then + 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 - git -C "${deploy_dir}" push local-bootstrap HEAD:main kubeconfig_probe="${KUBECONFIG_PATH:-${TF_VAR_kubeconfig_path:-${HOME}/.kube/config}}" action_command="${HOMELAB_ACTION_COMMAND:-auto}" - if [[ "${action_command}" == "auto" ]]; then - if [[ -s "${kubeconfig_probe}" ]]; then + if [ "${action_command}" = "auto" ]; then + if [ -s "${kubeconfig_probe}" ]; then set +e version_report="$("${deploy_dir}/jeannie" doctor-versions 2>&1)" version_status=$? set -e printf '%s\n' "${version_report}" - if ((version_status == 0)); then + if [ "${version_status}" -eq 0 ]; then action_command="apps" 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." @@ -209,7 +212,7 @@ jobs: "${deploy_dir}/jeannie" "${action_command}" ;; *) - echo "Unsupported HOMELAB_ACTION_COMMAND: ${action_command}" + echo "Unsupported HOMELAB_ACTION_COMMAND: ${action_command}" >&2 exit 1 ;; esac