diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 062d367..430f3c1 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -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