Упрощение кода: улучшена читаемость и форматирование скрипта создания конфигурации для деплоя
Deploy scripts to remote server / Upload and deploy on 192.168.10.14 (push) Failing after 1s

This commit is contained in:
Dmitriy Fofanov
2026-02-25 00:14:40 +03:00
parent a01e8452ca
commit dd4090cde4
+45 -45
View File
@@ -126,61 +126,61 @@ jobs:
rm -rf .deploy-artifacts/repo/.git .deploy-artifacts/repo/.src-repo .deploy-artifacts/repo/.wiki-repo .deploy-artifacts/repo/.deploy-artifacts
fi
python3 - <<'PY'
import json
import os
python3 - <<'PY'
import json
import os
def to_bool(value, default=False):
if value is None or value == "":
return default
return str(value).strip().lower() in {"1", "true", "yes", "on"}
def to_bool(value, default=False):
if value is None or value == "":
return default
return str(value).strip().lower() in {"1", "true", "yes", "on"}
def to_int(value, default):
if value is None or value == "":
return default
return int(value)
def to_int(value, default):
if value is None or value == "":
return default
return int(value)
domains_raw = os.environ.get("CFG_DOMAINS", "").strip()
if domains_raw.startswith("["):
# JSON array: каждый элемент может содержать запятые для SAN групп
# Пример: ["*.dfv24.com,dfv24.com", "github.dfv24.com"]
domains = json.loads(domains_raw)
else:
domains = [item.strip() for item in domains_raw.split(",") if item.strip()]
domains_raw = os.environ.get("CFG_DOMAINS", "").strip()
if domains_raw.startswith("["):
# JSON array: каждый элемент может содержать запятые для SAN групп
# Пример: ["*.dfv24.com,dfv24.com", "github.dfv24.com"]
domains = json.loads(domains_raw)
else:
domains = [item.strip() for item in domains_raw.split(",") if item.strip()]
if not domains:
raise RuntimeError("CFG_DOMAINS must contain at least one domain")
if not domains:
raise RuntimeError("CFG_DOMAINS must contain at least one domain")
# primary domain: первый домен из первой SAN группы
first_group_domains = [d.strip() for d in domains[0].split(",") if d.strip()]
domain = os.environ.get("CFG_DOMAIN", "").strip() or first_group_domains[0]
# primary domain: первый домен из первой SAN группы
first_group_domains = [d.strip() for d in domains[0].split(",") if d.strip()]
domain = os.environ.get("CFG_DOMAIN", "").strip() or first_group_domains[0]
config = {
"regru_username": os.environ["CFG_REGRU_USERNAME"],
"regru_password": os.environ["CFG_REGRU_PASSWORD"],
"domain": domain,
"domains": domains,
"wildcard": to_bool(os.environ.get("CFG_WILDCARD"), True),
"email": os.environ["CFG_EMAIL"],
"cert_dir": os.environ.get("CFG_CERT_DIR") or "/etc/letsencrypt/live",
"log_file": os.environ.get("CFG_LOG_FILE") or "/var/log/letsencrypt_regru.log",
"dns_propagation_wait": to_int(os.environ.get("CFG_DNS_PROPAGATION_WAIT"), 60),
"dns_check_attempts": to_int(os.environ.get("CFG_DNS_CHECK_ATTEMPTS"), 10),
"dns_check_interval": to_int(os.environ.get("CFG_DNS_CHECK_INTERVAL"), 10),
"renewal_days": to_int(os.environ.get("CFG_RENEWAL_DAYS"), 30),
"npm_enabled": to_bool(os.environ.get("CFG_NPM_ENABLED"), True),
"npm_host": os.environ.get("CFG_NPM_HOST") or "",
"npm_email": os.environ.get("CFG_NPM_EMAIL") or "",
"npm_password": os.environ.get("CFG_NPM_PASSWORD") or "",
}
config = {
"regru_username": os.environ["CFG_REGRU_USERNAME"],
"regru_password": os.environ["CFG_REGRU_PASSWORD"],
"domain": domain,
"domains": domains,
"wildcard": to_bool(os.environ.get("CFG_WILDCARD"), True),
"email": os.environ["CFG_EMAIL"],
"cert_dir": os.environ.get("CFG_CERT_DIR") or "/etc/letsencrypt/live",
"log_file": os.environ.get("CFG_LOG_FILE") or "/var/log/letsencrypt_regru.log",
"dns_propagation_wait": to_int(os.environ.get("CFG_DNS_PROPAGATION_WAIT"), 60),
"dns_check_attempts": to_int(os.environ.get("CFG_DNS_CHECK_ATTEMPTS"), 10),
"dns_check_interval": to_int(os.environ.get("CFG_DNS_CHECK_INTERVAL"), 10),
"renewal_days": to_int(os.environ.get("CFG_RENEWAL_DAYS"), 30),
"npm_enabled": to_bool(os.environ.get("CFG_NPM_ENABLED"), True),
"npm_host": os.environ.get("CFG_NPM_HOST") or "",
"npm_email": os.environ.get("CFG_NPM_EMAIL") or "",
"npm_password": os.environ.get("CFG_NPM_PASSWORD") or "",
}
output_path = os.path.join(".deploy-artifacts", "repo", "config.json")
with open(output_path, "w", encoding="utf-8") as file:
json.dump(config, file, ensure_ascii=False, indent=4)
PY
output_path = os.path.join(".deploy-artifacts", "repo", "config.json")
with open(output_path, "w", encoding="utf-8") as file:
json.dump(config, file, ensure_ascii=False, indent=4)
PY
tar -czf .deploy-artifacts/deploy.tar.gz -C .deploy-artifacts repo
ls -lh .deploy-artifacts/deploy.tar.gz