From 2a5ecebd99398074e496f6fd6b47413122d26080 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sat, 28 Feb 2026 18:36:58 +0000 Subject: [PATCH] fix: repair SSH key step quoting in workflows --- .gitea/workflows/kubeadm-bootstrap.yml | 7 ++++++- .gitea/workflows/kubeadm-reset.yml | 7 ++++++- .gitea/workflows/terraform-apply.yml | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/kubeadm-bootstrap.yml b/.gitea/workflows/kubeadm-bootstrap.yml index 82f3623..ae7dcd7 100644 --- a/.gitea/workflows/kubeadm-bootstrap.yml +++ b/.gitea/workflows/kubeadm-bootstrap.yml @@ -53,7 +53,12 @@ jobs: exit 1 fi - KEY_CONTENT="$KEY_CONTENT" python3 -c 'import os, pathlib; key=os.environ.get("KEY_CONTENT", "").replace("\r", "").strip(); key=key[1:-1] if len(key) > 2 and ((key[0] == "\"" and key[-1] == "\"") or (key[0] == "\'" and key[-1] == "\'")) else key; key=key.replace("\\n", "\n") if "\\n" in key and "\n" not in key else key; pathlib.Path.home().joinpath(".ssh", "id_ed25519").write_text(key if key.endswith("\n") else key + "\n")' + KEY_CONTENT="$(printf '%s' "$KEY_CONTENT" | tr -d '\r')" + if printf '%s' "$KEY_CONTENT" | grep -q '\\n'; then + printf '%b' "$KEY_CONTENT" > ~/.ssh/id_ed25519 + else + printf '%s\n' "$KEY_CONTENT" > ~/.ssh/id_ed25519 + fi chmod 0600 ~/.ssh/id_ed25519 if ! ssh-keygen -y -f ~/.ssh/id_ed25519 >/dev/null 2>&1; then diff --git a/.gitea/workflows/kubeadm-reset.yml b/.gitea/workflows/kubeadm-reset.yml index 6d13946..7c7c798 100644 --- a/.gitea/workflows/kubeadm-reset.yml +++ b/.gitea/workflows/kubeadm-reset.yml @@ -53,7 +53,12 @@ jobs: exit 1 fi - KEY_CONTENT="$KEY_CONTENT" python3 -c 'import os, pathlib; key=os.environ.get("KEY_CONTENT", "").replace("\r", "").strip(); key=key[1:-1] if len(key) > 2 and ((key[0] == "\"" and key[-1] == "\"") or (key[0] == "\'" and key[-1] == "\'")) else key; key=key.replace("\\n", "\n") if "\\n" in key and "\n" not in key else key; pathlib.Path.home().joinpath(".ssh", "id_ed25519").write_text(key if key.endswith("\n") else key + "\n")' + KEY_CONTENT="$(printf '%s' "$KEY_CONTENT" | tr -d '\r')" + if printf '%s' "$KEY_CONTENT" | grep -q '\\n'; then + printf '%b' "$KEY_CONTENT" > ~/.ssh/id_ed25519 + else + printf '%s\n' "$KEY_CONTENT" > ~/.ssh/id_ed25519 + fi chmod 0600 ~/.ssh/id_ed25519 if ! ssh-keygen -y -f ~/.ssh/id_ed25519 >/dev/null 2>&1; then diff --git a/.gitea/workflows/terraform-apply.yml b/.gitea/workflows/terraform-apply.yml index 6050a68..7a20fcd 100644 --- a/.gitea/workflows/terraform-apply.yml +++ b/.gitea/workflows/terraform-apply.yml @@ -96,7 +96,12 @@ jobs: exit 1 fi - KEY_CONTENT="$KEY_CONTENT" python3 -c 'import os, pathlib; key=os.environ.get("KEY_CONTENT", "").replace("\r", "").strip(); key=key[1:-1] if len(key) > 2 and ((key[0] == "\"" and key[-1] == "\"") or (key[0] == "\'" and key[-1] == "\'")) else key; key=key.replace("\\n", "\n") if "\\n" in key and "\n" not in key else key; pathlib.Path.home().joinpath(".ssh", "id_ed25519").write_text(key if key.endswith("\n") else key + "\n")' + KEY_CONTENT="$(printf '%s' "$KEY_CONTENT" | tr -d '\r')" + if printf '%s' "$KEY_CONTENT" | grep -q '\\n'; then + printf '%b' "$KEY_CONTENT" > ~/.ssh/id_ed25519 + else + printf '%s\n' "$KEY_CONTENT" > ~/.ssh/id_ed25519 + fi chmod 0600 ~/.ssh/id_ed25519 if ! ssh-keygen -y -f ~/.ssh/id_ed25519 >/dev/null 2>&1; then