""" generator/github_actions_generator.py ---------------------------------------- Renders github-actions.yml (lint/test/build/push/deploy), with the build-and-push and deploy steps adapted to the selected deployment target's real deploy mechanics — fully deterministic, no AI involvement. GitHub Actions expression syntax (`${{ ... }}`) uses the same double- curly-brace delimiters as Jinja2. To avoid Jinja2 trying to parse those as its own template expressions, every `${{ ... }}` token is built as a plain Python string here and passed into the template as a variable — the .j2 file itself never contains a literal `${{ }}`. """ from __future__ import annotations from utils.config import InfraConfig from utils.template_env import get_env from rules.kubernetes_rules import sanitize_dns_label class GitHubActionsGenerator: """Generates a CI/CD workflow, adapted to the selected deployment target.""" TEMPLATE_NAME = "github_actions/workflow.yml.j2" def generate(self, config: InfraConfig) -> str: namespace = sanitize_dns_label(config.project_name) image_tag = f"REGISTRY/{namespace}-app:" + "${{ github.sha }}" template = get_env().get_template(self.TEMPLATE_NAME) return template.render( deployment_target=config.deployment_target, cloud_provider=config.cloud_provider, namespace=namespace, image_tag=image_tag, gcp_sa_key_expr="${{ secrets.GCP_SA_KEY }}", registry_username_expr="${{ secrets.REGISTRY_USERNAME }}", registry_password_expr="${{ secrets.REGISTRY_PASSWORD }}", )