DevOps Pipeline Generator
Run ID: 69cc10ef04066a6c4a1690a42026-03-31Infrastructure
PantheraHive BOS
BOS Dashboard

This document provides comprehensive, detailed, and professional CI/CD pipeline configurations for GitHub Actions, GitLab CI, and Jenkins. Each configuration is designed to automate the software delivery process, covering essential stages such as linting, testing, building, and deployment.

We will use a common scenario: a Node.js application that is containerized using Docker and deployed to a generic server environment. This allows for clear demonstration of the core CI/CD principles across different platforms.


1. Common Scenario & Assumptions

To provide concrete and actionable examples, we'll base all pipeline configurations on the following assumptions:

* Node.js dependencies (npm install).

* Application build step (e.g., npm run build for frontend assets, or just ensuring dependencies are installed for a backend service).

* Docker image creation for containerization.

* Staging Environment: Deploys automatically on successful merges to main/master.

* Production Environment: Deploys manually or on a tag/release, after successful staging deployment.


2. GitHub Actions Pipeline Configuration

GitHub Actions provides a flexible and powerful CI/CD solution directly integrated into GitHub repositories.

2.1. Overview

This GitHub Actions workflow will:

  1. Trigger on pushes to the main branch and pull requests.
  2. Run linting and unit tests.
  3. Build a Docker image and push it to Docker Hub.
  4. Deploy the Docker image to a Staging server via SSH.
  5. Allow for a manual deployment to Production.

2.2. Key Pipeline Stages

2.3. Configuration File: .github/workflows/main.yml

yaml • 6,562 chars
name: Node.js CI/CD with Docker

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  workflow_dispatch: # Allows manual trigger for specific jobs

env:
  NODE_VERSION: '18.x' # Specify Node.js version
  DOCKER_IMAGE_NAME: my-nodejs-app # Name for your Docker image
  DOCKER_REGISTRY: docker.io # Or your specific registry, e.g., ghcr.io

jobs:
  lint:
    name: Lint Code
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Run ESLint
        run: npm run lint

  test:
    name: Run Tests
    needs: lint # Ensures linting passes before testing
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Run Jest tests
        run: npm run test -- --coverage # Example with coverage report

  build_and_push_docker_image:
    name: Build & Push Docker Image
    needs: test # Ensures tests pass before building
    runs-on: ubuntu-latest
    outputs:
      image_tag: ${{ steps.image_tag.outputs.tag }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Log in to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Get current date for image tag
        id: date
        run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')"
        # Note: '::set-output' is deprecated, use 'echo "output_name=value" >> $GITHUB_OUTPUT' in newer versions
        # For compatibility with older runners/actions, this example uses the older syntax.
        # For GHA runner version >= 2.297.0, use: echo "date=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT

      - name: Get commit SHA for image tag
        id: sha
        run: echo "::set-output name=sha::$(echo ${{ github.sha }} | cut -c1-7)"
        # For GHA runner version >= 2.297.0, use: echo "sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT

      - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: |
            ${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}:latest
            ${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.sha.outputs.sha }}
            ${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.date.outputs.date }}
          cache-from: type=gha
          cache-to: type=gha,mode=max

      - name: Set image tag output
        id: image_tag
        run: echo "::set-output name=tag::${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.sha.outputs.sha }}"
        # For GHA runner version >= 2.297.0, use: echo "tag=${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.sha.outputs.sha }}" >> $GITHUB_OUTPUT

  deploy_staging:
    name: Deploy to Staging
    needs: build_and_push_docker_image
    runs-on: ubuntu-latest
    environment: Staging # Link to a GitHub Environment for protection rules
    steps:
      - name: Deploy to Staging Server
        uses: appleboy/ssh-action@v1.0.0
        with:
          host: ${{ secrets.STAGING_SSH_HOST }}
          username: ${{ secrets.STAGING_SSH_USER }}
          key: ${{ secrets.STAGING_SSH_PRIVATE_KEY }}
          script: |
            # Navigate to application directory (adjust as needed)
            cd /opt/my-nodejs-app-staging
            # Log in to Docker registry on the server
            echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin ${{ env.DOCKER_REGISTRY }}
            # Pull the new Docker image
            docker pull ${{ needs.build_and_push_docker_image.outputs.image_tag }}
            # Stop existing container (if running)
            docker stop my-nodejs-app-staging || true
            docker rm my-nodejs-app-staging || true
            # Run new container
            docker run -d --name my-nodejs-app-staging -p 80:3000 ${{ needs.build_and_push_docker_image.outputs.image_tag }}
            echo "Deployment to Staging successful!"

  deploy_production:
    name: Deploy to Production
    needs: deploy_staging # Ensures staging deployment is successful
    runs-on: ubuntu-latest
    environment: Production # Link to a GitHub Environment for protection rules
    if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' # Only allow manual trigger or on main branch push
    # Note: For production, it's common to require manual approval or a tag/release trigger.
    # The 'workflow_dispatch' allows manual trigger, which can be configured with required approvals in GitHub Environments.
    steps:
      - name: Deploy to Production Server
        uses: appleboy/ssh-action@v1.0.0
        with:
          host: ${{ secrets.PROD_SSH_HOST }}
          username: ${{ secrets.PROD_SSH_USER }}
          key: ${{ secrets.PROD_SSH_PRIVATE_KEY }}
          script: |
            # Navigate to application directory (adjust as needed)
            cd /opt/my-nodejs-app-prod
            # Log in to Docker registry on the server
            echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin ${{ env.DOCKER_REGISTRY }}
            # Pull the new Docker image (using 'latest' for simplicity, but commit SHA tag is safer for prod)
            docker pull ${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}:latest
            # Stop existing container (if running)
            docker stop my-nodejs-app-prod || true
            docker rm my-nodejs-app-prod || true
            # Run new container
            docker run -d --name my-nodejs-app-prod -p 80:3000 ${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}:latest
            echo "Deployment to Production successful!"
Sandboxed live preview

DevOps Pipeline Generator: Infrastructure Needs Analysis

Introduction

This document presents a comprehensive analysis of the infrastructure considerations essential for designing and implementing a robust, efficient, and scalable CI/CD pipeline. As the foundational step in generating your custom DevOps pipeline configuration, understanding your underlying infrastructure, current processes, and future goals is paramount. This analysis aims to identify key requirements, potential challenges, and strategic recommendations to ensure the generated pipeline perfectly aligns with your operational landscape.

Executive Summary

To deliver an optimal CI/CD pipeline configuration (GitHub Actions, GitLab CI, or Jenkins), a thorough understanding of your infrastructure is critical. This initial analysis identifies the core pillars of a successful CI/CD ecosystem: Source Code Management (SCM), application architecture, build environments, testing frameworks, deployment targets, and security protocols. Without specific customer input on existing infrastructure, this document outlines the crucial data points required for effective pipeline generation.

Key trends emphasize cloud-native solutions, containerization, Infrastructure as Code (IaC), and integrated security ("Shift Left"). Our recommendations focus on modularity, automation, security, and cost-efficiency. The immediate next step is to gather specific details regarding your current and desired infrastructure, which will directly inform the subsequent pipeline design phase.

1. Understanding Your Current & Desired Infrastructure (Framework for Analysis)

To generate an effective CI/CD pipeline, we need to gather specific details about your environment. Below is a framework outlining the critical information required.

1.1. Source Code Management (SCM) & Preferred CI/CD Platform

  • Current SCM Platform:

* GitHub (GitHub.com, GitHub Enterprise)

* GitLab (GitLab.com, GitLab Self-Managed)

* Bitbucket (Cloud, Server/Data Center)

* Azure DevOps Repos

* Other (e.g., AWS CodeCommit, self-hosted Git)

  • Preferred CI/CD Orchestration Tool:

* GitHub Actions

* GitLab CI/CD

* Jenkins

* Azure Pipelines

* CircleCI, Travis CI, etc.

Note: If no preference, we can recommend based on SCM.*

  • Reason for Preference (if any): Existing team familiarity, compliance, cost, features.

1.2. Application Architecture & Technology Stack

  • Application Type:

* Monolith

* Microservices (number of services, inter-service communication)

* Serverless (Functions, APIs)

* Mobile (iOS, Android, React Native, Flutter)

* Desktop (Windows, macOS, Linux)

* Static Website/SPA (React, Angular, Vue)

* Other (e.g., IoT, Embedded)

  • Programming Languages & Frameworks:

* Java (Spring Boot, Quarkus, Maven, Gradle)

* Python (Django, Flask, FastAPI, Poetry, Pipenv)

* Node.js (Express, NestJS, React, Angular, Vue, NPM, Yarn)

* Go (Gin, Echo, Go Modules)

* .NET (C#, ASP.NET Core, NuGet)

* Ruby (Rails, Bundler)

* PHP (Laravel, Symfony, Composer)

* Other (e.g., Rust, Scala, Kotlin)

  • Database Technologies:

* Relational: PostgreSQL, MySQL, SQL Server, Oracle, MariaDB

* NoSQL: MongoDB, Cassandra, DynamoDB, Redis, Elasticsearch

* Data Warehousing: Snowflake, Redshift, BigQuery

  • Containerization:

* Are you currently using Docker?

* Are you planning to containerize your applications?

  • Virtualization:

* Are you using Virtual Machines (VMs) for development/production?

  • Infrastructure as Code (IaC):

* Terraform, CloudFormation, Azure ARM Templates, Pulumi, Ansible.

* Existing IaC practices?

1.3. Build & Test Environment Needs

  • Build Runners:

* Managed/Cloud-hosted runners (e.g., GitHub-hosted runners, GitLab Shared Runners, Jenkins agents on cloud VMs)

* Self-hosted runners (on-premises, custom cloud VMs)

* Specific OS requirements for builds (Linux, Windows, macOS)?

* Specific hardware requirements (e.g., GPU for ML models)?

  • Build Tools: Maven, Gradle, npm, yarn, pip, go build, dotnet build, Docker build.
  • Testing Frameworks:

* Unit Testing: JUnit, Pytest, Jest, GoConvey, NUnit

* Integration Testing: Testcontainers, Mockito, Cypress

* End-to-End (E2E) Testing: Selenium, Playwright, Cypress, Puppeteer

* Performance Testing: JMeter, K6, LoadRunner

* Security Testing: SAST (SonarQube, Snyk), DAST (OWASP ZAP), SCA (Dependabot, Snyk)

  • Code Quality/Linting Tools: SonarQube, ESLint, Black, Prettier, RuboCop.
  • Artifact Management:

* Container Registries: Docker Hub, AWS ECR, Azure Container Registry, Google Container Registry, GitLab Container Registry.

* Package Registries: Nexus, Artifactory, npm registry, Maven Central.

1.4. Deployment Targets & Strategy

  • Cloud Provider(s):

* AWS (EC2, ECS, EKS, Lambda, S3, Amplify, Lightsail)

* Azure (VMs, AKS, Azure Functions, App Service, Static Web Apps)

* Google Cloud Platform (GCE, GKE, Cloud Functions, App Engine, Cloud Run)

* Other (DigitalOcean, Heroku, Vercel, Netlify, Render)

  • On-Premises Infrastructure:

* Virtual Machines (VMware, Hyper-V, KVM)

* Kubernetes Clusters (OpenShift, Rancher, bare-metal K8s)

* Bare Metal Servers

  • Deployment Strategy:

* Rolling Updates

* Blue/Green Deployments

* Canary Releases

* Feature Flags

* Serverless deployments

  • Existing Deployment Tools: Helm, Kubernetes manifests, Ansible, Chef, Puppet, custom scripts.

1.5. Security, Secrets Management & Compliance

  • Secrets Management:

* Cloud-native solutions (AWS Secrets Manager, Azure Key Vault, GCP Secret Manager)

* HashiCorp Vault

* Environment variables, CI/CD platform secrets

  • Identity and Access Management (IAM):

* How are permissions managed for CI/CD tools to access cloud resources? (IAM Roles, Service Principals, Service Accounts)

  • Compliance Requirements: GDPR, HIPAA, SOC 2, PCI DSS.
  • Network Security: Private endpoints, VPCs, firewalls, network segmentation.

1.6. Monitoring, Logging & Alerting

  • Logging: ELK Stack (Elasticsearch, Logstash, Kibana), Splunk, Datadog, CloudWatch Logs, Azure Monitor Logs, GCP Cloud Logging.
  • Monitoring: Prometheus, Grafana, Datadog, New Relic, AppDynamics, CloudWatch, Azure Monitor, GCP Cloud Monitoring.
  • Alerting: PagerDuty, Opsgenie, Slack, Microsoft Teams, Email.

1.7. Cost & Performance Considerations

  • Budget Constraints: For cloud resources, managed services, and CI/CD tools.
  • Performance Requirements: Latency, throughput, scalability (e.g., expected peak load, number of concurrent users).
  • High Availability / Disaster Recovery (HA/DR): RTO (Recovery Time Objective), RPO (Recovery Point Objective).

2. Data Insights & Industry Trends

The DevOps landscape is continuously evolving. Understanding key trends helps in designing a future-proof CI/CD pipeline.

  • Cloud-Native Adoption: A significant shift towards cloud platforms (AWS, Azure, GCP) for hosting applications and CI/CD infrastructure. This offers scalability, managed services, and reduced operational overhead.

Insight*: 70% of organizations are leveraging cloud-native architectures for new applications (CNCF Survey).

  • Containerization & Kubernetes: Docker and Kubernetes have become the de facto standards for packaging and orchestrating applications. This ensures consistency across development, testing, and production environments.

Insight*: Over 90% of enterprises using containers are using Kubernetes in production (Red Hat State of Kubernetes report).

  • Infrastructure as Code (IaC): Automating infrastructure provisioning and management using tools like Terraform, CloudFormation, and Ansible. IaC promotes consistency, reduces manual errors, and enables version control of infrastructure.

Insight*: Organizations using IaC report 2-3x faster infrastructure provisioning times.

  • Shift-Left Security: Integrating security practices and tools early in the development lifecycle (SAST, DAST, SCA, secrets management). This reduces vulnerabilities and remediation costs.

Insight*: Fixing security vulnerabilities in the design phase costs 10x less than fixing them in production.

  • GitOps: A paradigm that extends IaC to operations, using Git as the single source of truth for declarative infrastructure and applications. This enhances collaboration, auditability, and automation.
  • Serverless Computing: Increasing adoption of serverless functions (AWS Lambda, Azure Functions, GCP Cloud Functions) for event-driven architectures, reducing operational burden further.
  • AI/ML in DevOps: Emerging trend of using AI/ML for predictive analytics, anomaly detection, automated testing, and intelligent resource allocation in CI/CD.
  • Observability over Monitoring: Moving beyond simple metrics to comprehensive logging, tracing, and metrics for deeper insights into application behavior and performance.

3. Strategic Recommendations

Based on the general principles of modern DevOps and the outlined infrastructure considerations, we recommend the following strategic approaches:

  1. Prioritize Cloud-Native Services: Leverage managed services from your chosen cloud provider (e.g., managed Kubernetes, serverless functions, managed databases, secrets managers). This reduces operational overhead, improves scalability, and often enhances security.
  2. Embrace Containerization: Standardize on Docker for application packaging. This ensures environmental consistency from development to production and simplifies deployment to Kubernetes or other container orchestration platforms.
  3. Implement Infrastructure as Code (IaC): Automate the provisioning and configuration of your infrastructure using tools like Terraform. This brings version control, repeatability, and disaster recovery benefits to your infrastructure.
  4. Adopt a "Shift-Left" Security Posture: Integrate security scanning (SAST, SCA) directly into your CI pipeline. Utilize robust secrets management solutions (e.g., cloud-native secret managers or HashiCorp Vault) to protect sensitive credentials.
  5. Standardize on a Single CI/CD Platform: Consolidate your CI/CD efforts on one platform (GitHub Actions, GitLab CI, or Jenkins) to reduce complexity, leverage common tooling, and streamline team training. The choice should align with your SCM and team familiarity.
  6. Modular Pipeline Design: Design pipelines with clear, independent stages (lint, test, build, deploy). This enhances maintainability, allows for easier debugging, and supports independent scaling of pipeline steps.
  7. Automate Everything: Strive to automate every step of the CI/CD process, from code commit to production deployment. Manual steps introduce errors and slow down delivery.
  8. Implement Comprehensive Observability: Integrate logging, monitoring, and tracing tools into your application and infrastructure. This provides critical visibility into pipeline performance, application health, and potential issues.
  9. Consider Self-Hosted Runners for Specific Needs: While managed runners are convenient, self-hosted runners might be necessary for specific hardware requirements (e.g., GPU, large memory), specific OS, or strict network isolation/compliance.
  10. Cost Optimization: Regularly review cloud resource usage and CI/CD runner consumption. Leverage cost-saving features like spot instances for non-critical builds, or optimize container images to reduce build times and storage.

4. Next Steps & Call to Action

To proceed with generating the precise and effective CI/CD pipeline configurations, we require detailed information about your specific infrastructure.

Action Required from Customer:

Please provide specific answers to the questions outlined in Section 1: Understanding Your Current & Desired Infrastructure (Framework for Analysis). The more detailed and accurate your responses, the more tailored and effective the generated CI/CD pipeline will be.

Once we receive this critical information, we will move to Step 2: Generate Pipeline Configurations,

2.4. Detailed Explanation of the Configuration

  • name: The name of the workflow.
  • on: Defines when the workflow runs.

* push to main: Triggers on every push to the main branch.

* pull_request to main: Triggers on pull requests targeting main.

* workflow_dispatch: Allows manual triggering of the workflow from the GitHub UI.

  • env: Global environment variables for the workflow.
  • jobs: A workflow run is made up of one or more jobs.

* lint:

* runs-on: ubuntu-latest: Specifies the runner environment.

* uses: actions/checkout@v4: Checks out your repository code.

* uses: actions/setup-node@v4: Sets up the Node.js environment.

* npm ci: Installs dependencies from package-lock.json (recommended for CI).

* npm run lint: Executes the linting script defined in package.json.

* test:

* needs: lint: Ensures this job only runs after lint completes successfully.

* Similar setup to lint, then runs npm run test.

* build_and_push_docker_image:

* needs: test: Ensures this job only runs after test completes successfully.

* uses: docker/setup-buildx-action@v3: Sets up Docker Buildx for advanced Docker features.

* uses: docker/login-action@v3: Logs into Docker Hub using secrets.

steps.date & steps.sha: Generate dynamic tags for the Docker image (timestamp and short commit SHA). Note the comment about ::set-output deprecation.*

* uses: docker/build-push-action@v5: Builds the Docker image and pushes it to Docker Hub with multiple tags (latest, commit SHA, timestamp).

* outputs: image_tag: Makes the generated image tag available to subsequent jobs.

* deploy_staging:

* needs: build_and_push_docker_image: Depends on the Docker image being built and pushed.

* environment: Staging: Links to a GitHub Environment, allowing for protection rules (e.g., required

gemini Output

DevOps Pipeline Generation: Comprehensive CI/CD Configurations

This document provides detailed, professional, and actionable CI/CD pipeline configurations for three leading platforms: GitHub Actions, GitLab CI, and Jenkins. Each configuration includes essential stages such as linting, testing, building, and deployment, designed to establish a robust and automated software delivery process. These templates are generic and designed to be highly customizable for various project types (e.g., Node.js, Python, Java, Go, Dockerized applications).


1. Introduction and Overview

Automating the software delivery lifecycle is crucial for modern development teams. This deliverable provides foundational CI/CD pipeline configurations that streamline your development workflow, enhance code quality, accelerate deployments, and improve overall team efficiency. By integrating linting, testing, building, and deployment into an automated pipeline, you ensure consistent quality and faster time-to-market.

Key Benefits:

  • Consistency: Standardized process for every code change.
  • Quality Assurance: Automated checks reduce bugs and technical debt.
  • Speed: Faster feedback loops and quicker deployments.
  • Reliability: Reduced human error in build and deployment processes.
  • Traceability: Clear history of changes, builds, and deployments.

2. Core CI/CD Principles and Stages

Each pipeline configuration adheres to the following core CI/CD principles, breaking down the process into distinct, manageable stages:

  • Linting/Static Analysis: Automatically checks code for stylistic issues, potential errors, and adherence to coding standards without executing the code.

* Purpose: Improve code readability, maintainability, and catch common mistakes early.

  • Testing: Executes various types of tests (unit, integration, end-to-end) to validate the functionality and correctness of the application.

* Purpose: Ensure new features work as expected and existing functionality remains unbroken.

  • Building: Compiles source code, resolves dependencies, and packages the application into a deployable artifact (e.g., a JAR file, a Docker image, a compiled binary, an npm package).

* Purpose: Create a consistent, versioned output ready for deployment.

  • Deployment: Automates the process of releasing the built artifact to various environments (development, staging, production).

* Purpose: Enable rapid and reliable delivery of applications to users. This stage often includes environment-specific configurations and approval gates for production.


3. Generated Pipeline Configurations

Below are comprehensive templates for GitHub Actions, GitLab CI, and Jenkins. Each template is heavily commented to explain its purpose and includes placeholders for easy customization.

3.1. GitHub Actions Pipeline

Overview: GitHub Actions provides a powerful and flexible CI/CD platform directly integrated with your GitHub repositories. Workflows are defined in YAML files (.github/workflows/) and can be triggered by various GitHub events.

Key Features:

  • Event-Driven: Triggered by push, pull_request, schedule, workflow_dispatch (manual), etc.
  • Matrix Builds: Run jobs across multiple OS, Node.js versions, etc.
  • Marketplace Actions: Reusable actions simplify complex tasks.
  • Secrets Management: Securely store sensitive information.

pipeline.yml Example:


# .github/workflows/pipeline.yml

name: CI/CD Pipeline

# Controls when the workflow will run
on:
  push:
    branches:
      - main
      - develop
  pull_request:
    branches:
      - main
      - develop
  workflow_dispatch: # Allows manual trigger

# Define reusable environment variables
env:
  NODE_VERSION: '18.x' # Example for Node.js project
  DOCKER_IMAGE_NAME: your-app-name # Replace with your application name
  DOCKER_REGISTRY: ghcr.io/${{ github.repository_owner }} # Or your Docker Hub/ECR/GCR registry

jobs:
  # --------------------------------------------------------------------------------------------------
  # Stage 1: Linting
  # --------------------------------------------------------------------------------------------------
  lint:
    name: Lint Code
    runs-on: ubuntu-latest # Specify the runner environment

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js (if applicable)
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'npm' # Caches npm dependencies

      - name: Install dependencies (if applicable)
        run: npm ci # Or 'yarn install' for Yarn

      - name: Run Linter (e.g., ESLint, Prettier, Flake8)
        # Replace with your specific linting command
        run: npm run lint || true # '|| true' allows the job to succeed even if lint errors are found, but logs them. Remove for strict enforcement.
        # Example for Python: pip install flake8 && flake8 .
        # Example for Go: go vet ./...

  # --------------------------------------------------------------------------------------------------
  # Stage 2: Testing
  # --------------------------------------------------------------------------------------------------
  test:
    name: Run Tests
    runs-on: ubuntu-latest
    needs: lint # This job depends on the 'lint' job completing successfully

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js (if applicable)
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'npm'

      - name: Install dependencies (if applicable)
        run: npm ci

      - name: Run Unit and Integration Tests
        # Replace with your specific test command
        run: npm test # Or 'jest', 'pytest', 'go test ./...'

      - name: Upload test results (e.g., for coverage reports)
        if: always() # Always run this step even if tests fail
        uses: actions/upload-artifact@v4
        with:
          name: test-results
          path: ./coverage # Example path, adjust as needed

  # --------------------------------------------------------------------------------------------------
  # Stage 3: Building (and potentially Dockerizing)
  # --------------------------------------------------------------------------------------------------
  build:
    name: Build Application
    runs-on: ubuntu-latest
    needs: test # This job depends on the 'test' job completing successfully

    outputs:
      # Pass the generated image tag to subsequent jobs
      image_tag: ${{ steps.docker_build_and_push.outputs.image_tag }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      # --- Conditional steps for non-Dockerized builds (e.g., JAR, npm package) ---
      - name: Set up Node.js (if applicable for non-Docker build)
        if: false # Set to true if building a non-Docker Node.js artifact
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'npm'

      - name: Install dependencies (if applicable for non-Docker build)
        if: false # Set to true if building a non-Docker Node.js artifact
        run: npm ci

      - name: Build application artifact (e.g., Vue/React build, Java JAR)
        if: false # Set to true if building a non-Docker artifact
        # Replace with your specific build command
        run: npm run build # Example: 'mvn package', 'go build -o app'

      - name: Upload application artifact
        if: false # Set to true if building a non-Docker artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.DOCKER_IMAGE_NAME }}-artifact
          path: ./dist # Example path to your built artifact

      # --- Conditional steps for Dockerized builds ---
      - name: Log in to Docker Registry
        if: true # Set to false if not building a Docker image
        uses: docker/login-action@v3
        with:
          registry: ${{ env.DOCKER_REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }} # Use GITHUB_TOKEN for GHCR, or a specific secret for others

      - name: Set up Docker BuildX
        if: true
        uses: docker/setup-buildx-action@v3

      - name: Build and push Docker image
        id: docker_build_and_push
        if: true
        uses: docker/build-push-action@v5
        with:
          context: . # Path to the Dockerfile context
          file: ./Dockerfile # Path to your Dockerfile
          push: true
          tags: |
            ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }}
            ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:latest # Optional: push 'latest' tag on main branch
          build-args: |
            # Example build arg: ENV_VAR=value
          cache-from: type=gha
          cache-to: type=gha,mode=max

  # --------------------------------------------------------------------------------------------------
  # Stage 4: Deployment to Development/Staging Environment
  # --------------------------------------------------------------------------------------------------
  deploy-dev:
    name: Deploy to Development
    runs-on: ubuntu-latest
    needs: build # This job depends on the 'build' job completing successfully
    environment:
      name: Development # Define an environment for better visibility and protection rules
      url: https://dev.your-app.com # Optional: URL to the deployed application

    # Only deploy to dev/staging on pushes to 'develop' branch or manual trigger
    if: github.ref == 'refs/heads/develop' || github.event_name == 'workflow_dispatch'

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Download artifact (if not using Docker)
        if: false # Set to true if deploying a non-Docker artifact
        uses: actions/download-artifact@v4
        with:
          name: ${{ env.DOCKER_IMAGE_NAME }}-artifact
          path: ./deploy-artifact

      - name: Deploy to Development Server (e.g., SSH, Kubernetes, AWS ECS/EC2)
        # Replace with your specific deployment commands
        run: |
          echo "Deploying ${{ needs.build.outputs.image_tag || 'artifact' }} to development..."
          # Example for SSH deployment:
          # ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no user@${{ secrets.DEV_SERVER_IP }} "
          #   docker pull ${{ needs.build.outputs.image_tag }} &&
          #   docker stop ${{ env.DOCKER_IMAGE_NAME }} || true &&
          #   docker rm ${{ env.DOCKER_IMAGE_NAME }} || true &&
          #   docker run -d --name ${{ env.DOCKER_IMAGE_NAME }} -p 80:80 ${{ needs.build.outputs.image_tag }}
          # "
          # Example for Kubernetes (using kubectl):
          # kubectl config use-context your-k8s-cluster-dev
          # kubectl set image deployment/your-app-dev your-container=${{ needs.build.outputs.image_tag }} -n your-namespace-dev
        env:
          DEV_SERVER_IP: ${{ secrets.DEV_SERVER_IP }} # Store sensitive data in GitHub Secrets
          SSH_KEY: ${{ secrets.DEV_SSH_PRIVATE_KEY }} # Store SSH key in secrets

  # --------------------------------------------------------------------------------------------------
  # Stage 5: Deployment to Production Environment (with manual approval)
  # --------------------------------------------------------------------------------------------------
  deploy-prod:
    name: Deploy to Production
    runs-on: ubuntu-latest
    needs: deploy-dev # Production deployment should ideally follow successful staging deployment and testing
    environment:
      name: Production
      url: https://your-app.com

    # Only deploy to production on pushes to 'main' branch or manual trigger, AND after successful staging
    if: github.ref == 'refs/heads/main' && github.event_name == 'push' || github.event_name == 'workflow_dispatch'

    # Requires manual approval before proceeding
    environment:
      name:
devops_pipeline_generator.txt
Download source file
Copy all content
Full output as text
Download ZIP
IDE-ready project ZIP
Copy share link
Permanent URL for this run
Get Embed Code
Embed this result on any website
Print / Save PDF
Use browser print dialog
\n\n\n"); var hasSrcMain=Object.keys(extracted).some(function(k){return k.indexOf("src/main")>=0;}); if(!hasSrcMain) zip.file(folder+"src/main."+ext,"import React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport App from './App'\nimport './index.css'\n\nReactDOM.createRoot(document.getElementById('root')!).render(\n \n \n \n)\n"); var hasSrcApp=Object.keys(extracted).some(function(k){return k==="src/App."+ext||k==="App."+ext;}); if(!hasSrcApp) zip.file(folder+"src/App."+ext,"import React from 'react'\nimport './App.css'\n\nfunction App(){\n return(\n
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n
\n )\n}\nexport default App\n"); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e}\n.app{min-height:100vh;display:flex;flex-direction:column}\n.app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px}\nh1{font-size:2.5rem;font-weight:700}\n"); zip.file(folder+"src/App.css",""); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/pages/.gitkeep",""); zip.file(folder+"src/hooks/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\n## Open in IDE\nOpen the project folder in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- Vue (Vite + Composition API + TypeScript) --- */ function buildVue(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "type": "module",\n "scripts": {\n "dev": "vite",\n "build": "vue-tsc -b && vite build",\n "preview": "vite preview"\n },\n "dependencies": {\n "vue": "^3.5.13",\n "vue-router": "^4.4.5",\n "pinia": "^2.3.0",\n "axios": "^1.7.9"\n },\n "devDependencies": {\n "@vitejs/plugin-vue": "^5.2.1",\n "typescript": "~5.7.3",\n "vite": "^6.0.5",\n "vue-tsc": "^2.2.0"\n }\n}\n'); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport { resolve } from 'path'\n\nexport default defineConfig({\n plugins: [vue()],\n resolve: { alias: { '@': resolve(__dirname,'src') } }\n})\n"); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]}\n'); zip.file(folder+"tsconfig.app.json",'{\n "compilerOptions":{\n "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"],\n "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true,\n "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue",\n "strict":true,"paths":{"@/*":["./src/*"]}\n },\n "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"]\n}\n'); zip.file(folder+"env.d.ts","/// \n"); zip.file(folder+"index.html","\n\n\n \n \n "+slugTitle(pn)+"\n\n\n
\n \n\n\n"); var hasMain=Object.keys(extracted).some(function(k){return k==="src/main.ts"||k==="main.ts";}); if(!hasMain) zip.file(folder+"src/main.ts","import { createApp } from 'vue'\nimport { createPinia } from 'pinia'\nimport App from './App.vue'\nimport './assets/main.css'\n\nconst app = createApp(App)\napp.use(createPinia())\napp.mount('#app')\n"); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue","\n\n\n\n\n"); zip.file(folder+"src/assets/main.css","*{margin:0;padding:0;box-sizing:border-box}body{font-family:system-ui,sans-serif;background:#fff;color:#213547}\n"); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/views/.gitkeep",""); zip.file(folder+"src/stores/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\nOpen in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- Angular (v19 standalone) --- */ function buildAngular(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var sel=pn.replace(/_/g,"-"); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "scripts": {\n "ng": "ng",\n "start": "ng serve",\n "build": "ng build",\n "test": "ng test"\n },\n "dependencies": {\n "@angular/animations": "^19.0.0",\n "@angular/common": "^19.0.0",\n "@angular/compiler": "^19.0.0",\n "@angular/core": "^19.0.0",\n "@angular/forms": "^19.0.0",\n "@angular/platform-browser": "^19.0.0",\n "@angular/platform-browser-dynamic": "^19.0.0",\n "@angular/router": "^19.0.0",\n "rxjs": "~7.8.0",\n "tslib": "^2.3.0",\n "zone.js": "~0.15.0"\n },\n "devDependencies": {\n "@angular-devkit/build-angular": "^19.0.0",\n "@angular/cli": "^19.0.0",\n "@angular/compiler-cli": "^19.0.0",\n "typescript": "~5.6.0"\n }\n}\n'); zip.file(folder+"angular.json",'{\n "$schema": "./node_modules/@angular/cli/lib/config/schema.json",\n "version": 1,\n "newProjectRoot": "projects",\n "projects": {\n "'+pn+'": {\n "projectType": "application",\n "root": "",\n "sourceRoot": "src",\n "prefix": "app",\n "architect": {\n "build": {\n "builder": "@angular-devkit/build-angular:application",\n "options": {\n "outputPath": "dist/'+pn+'",\n "index": "src/index.html",\n "browser": "src/main.ts",\n "tsConfig": "tsconfig.app.json",\n "styles": ["src/styles.css"],\n "scripts": []\n }\n },\n "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"}\n }\n }\n }\n}\n'); zip.file(folder+"tsconfig.json",'{\n "compileOnSave": false,\n "compilerOptions": {"baseUrl":"./","outDir":"./dist/out-tsc","forceConsistentCasingInFileNames":true,"strict":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"paths":{"@/*":["src/*"]},"skipLibCheck":true,"esModuleInterop":true,"sourceMap":true,"declaration":false,"experimentalDecorators":true,"moduleResolution":"bundler","importHelpers":true,"target":"ES2022","module":"ES2022","useDefineForClassFields":false,"lib":["ES2022","dom"]},\n "references":[{"path":"./tsconfig.app.json"}]\n}\n'); zip.file(folder+"tsconfig.app.json",'{\n "extends":"./tsconfig.json",\n "compilerOptions":{"outDir":"./dist/out-tsc","types":[]},\n "files":["src/main.ts"],\n "include":["src/**/*.d.ts"]\n}\n'); zip.file(folder+"src/index.html","\n\n\n \n "+slugTitle(pn)+"\n \n \n \n\n\n \n\n\n"); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser';\nimport { appConfig } from './app/app.config';\nimport { AppComponent } from './app/app.component';\n\nbootstrapApplication(AppComponent, appConfig)\n .catch(err => console.error(err));\n"); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; }\nbody { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; }\n"); var hasComp=Object.keys(extracted).some(function(k){return k.indexOf("app.component")>=0;}); if(!hasComp){ zip.file(folder+"src/app/app.component.ts","import { Component } from '@angular/core';\nimport { RouterOutlet } from '@angular/router';\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [RouterOutlet],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css'\n})\nexport class AppComponent {\n title = '"+pn+"';\n}\n"); zip.file(folder+"src/app/app.component.html","
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n \n
\n"); zip.file(folder+"src/app/app.component.css",".app-header{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:60vh;gap:16px}h1{font-size:2.5rem;font-weight:700;color:#6366f1}\n"); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';\nimport { provideRouter } from '@angular/router';\nimport { routes } from './app.routes';\n\nexport const appConfig: ApplicationConfig = {\n providers: [\n provideZoneChangeDetection({ eventCoalescing: true }),\n provideRouter(routes)\n ]\n};\n"); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router';\n\nexport const routes: Routes = [];\n"); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nng serve\n# or: npm start\n\`\`\`\n\n## Build\n\`\`\`bash\nng build\n\`\`\`\n\nOpen in VS Code with Angular Language Service extension.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n.angular/\n"); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/m,"").trim(); var reqMap={"numpy":"numpy","pandas":"pandas","sklearn":"scikit-learn","tensorflow":"tensorflow","torch":"torch","flask":"flask","fastapi":"fastapi","uvicorn":"uvicorn","requests":"requests","sqlalchemy":"sqlalchemy","pydantic":"pydantic","dotenv":"python-dotenv","PIL":"Pillow","cv2":"opencv-python","matplotlib":"matplotlib","seaborn":"seaborn","scipy":"scipy"}; var reqs=[]; Object.keys(reqMap).forEach(function(k){if(src.indexOf("import "+k)>=0||src.indexOf("from "+k)>=0)reqs.push(reqMap[k]);}); var reqsTxt=reqs.length?reqs.join("\n"):"# add dependencies here\n"; zip.file(folder+"main.py",src||"# "+title+"\n# Generated by PantheraHive BOS\n\nprint(title+\" loaded\")\n"); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n\`\`\`\n\n## Run\n\`\`\`bash\npython main.py\n\`\`\`\n"); zip.file(folder+".gitignore",".venv/\n__pycache__/\n*.pyc\n.env\n.DS_Store\n"); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/m,"").trim(); var depMap={"mongoose":"^8.0.0","dotenv":"^16.4.5","axios":"^1.7.9","cors":"^2.8.5","bcryptjs":"^2.4.3","jsonwebtoken":"^9.0.2","socket.io":"^4.7.4","uuid":"^9.0.1","zod":"^3.22.4","express":"^4.18.2"}; var deps={}; Object.keys(depMap).forEach(function(k){if(src.indexOf(k)>=0)deps[k]=depMap[k];}); if(!deps["express"])deps["express"]="^4.18.2"; var pkgJson=JSON.stringify({"name":pn,"version":"1.0.0","main":"src/index.js","scripts":{"start":"node src/index.js","dev":"nodemon src/index.js"},"dependencies":deps,"devDependencies":{"nodemon":"^3.0.3"}},null,2)+"\n"; zip.file(folder+"package.json",pkgJson); var fallback="const express=require(\"express\");\nconst app=express();\napp.use(express.json());\n\napp.get(\"/\",(req,res)=>{\n res.json({message:\""+title+" API\"});\n});\n\nconst PORT=process.env.PORT||3000;\napp.listen(PORT,()=>console.log(\"Server on port \"+PORT));\n"; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000\n"); zip.file(folder+".gitignore","node_modules/\n.env\n.DS_Store\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\n\`\`\`\n\n## Run\n\`\`\`bash\nnpm run dev\n\`\`\`\n"); } /* --- Vanilla HTML --- */ function buildVanillaHtml(zip,folder,app,code){ var title=slugTitle(app); var isFullDoc=code.trim().toLowerCase().indexOf("=0||code.trim().toLowerCase().indexOf("=0; var indexHtml=isFullDoc?code:"\n\n\n\n\n"+title+"\n\n\n\n"+code+"\n\n\n\n"; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */\n*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e}\n"); zip.file(folder+"script.js","/* "+title+" — scripts */\n"); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Open\nDouble-click \`index.html\` in your browser.\n\nOr serve locally:\n\`\`\`bash\nnpx serve .\n# or\npython3 -m http.server 3000\n\`\`\`\n"); zip.file(folder+".gitignore",".DS_Store\nnode_modules/\n.env\n"); } /* ===== MAIN ===== */ var sc=document.createElement("script"); sc.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"; sc.onerror=function(){ if(lbl)lbl.textContent="Download ZIP"; alert("JSZip load failed — check connection."); }; sc.onload=function(){ var zip=new JSZip(); var base=(_phFname||"output").replace(/\.[^.]+$/,""); var app=base.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"my_app"; var folder=app+"/"; var vc=document.getElementById("panel-content"); var panelTxt=vc?(vc.innerText||vc.textContent||""):""; var lang=detectLang(_phCode,panelTxt); if(_phIsHtml){ buildVanillaHtml(zip,folder,app,_phCode); } else if(lang==="flutter"){ buildFlutter(zip,folder,app,_phCode,panelTxt); } else if(lang==="react-native"){ buildReactNative(zip,folder,app,_phCode,panelTxt); } else if(lang==="swift"){ buildSwift(zip,folder,app,_phCode,panelTxt); } else if(lang==="kotlin"){ buildKotlin(zip,folder,app,_phCode,panelTxt); } else if(lang==="react"){ buildReact(zip,folder,app,_phCode,panelTxt); } else if(lang==="vue"){ buildVue(zip,folder,app,_phCode,panelTxt); } else if(lang==="angular"){ buildAngular(zip,folder,app,_phCode,panelTxt); } else if(lang==="python"){ buildPython(zip,folder,app,_phCode); } else if(lang==="node"){ buildNode(zip,folder,app,_phCode); } else { /* Document/content workflow */ var title=app.replace(/_/g," "); var md=_phAll||_phCode||panelTxt||"No content"; zip.file(folder+app+".md",md); var h=""+title+""; h+="

"+title+"

"; var hc=md.replace(/&/g,"&").replace(//g,">"); hc=hc.replace(/^### (.+)$/gm,"

$1

"); hc=hc.replace(/^## (.+)$/gm,"

$1

"); hc=hc.replace(/^# (.+)$/gm,"

$1

"); hc=hc.replace(/\*\*(.+?)\*\*/g,"$1"); hc=hc.replace(/\n{2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\nFiles:\n- "+app+".md (Markdown)\n- "+app+".html (styled HTML)\n"); } zip.generateAsync({type:"blob"}).then(function(blob){ var a=document.createElement("a"); a.href=URL.createObjectURL(blob); a.download=app+".zip"; a.click(); URL.revokeObjectURL(a.href); if(lbl)lbl.textContent="Download ZIP"; }); }; document.head.appendChild(sc); } function phShare(){navigator.clipboard.writeText(window.location.href).then(function(){var el=document.getElementById("ph-share-lbl");if(el){el.textContent="Link copied!";setTimeout(function(){el.textContent="Copy share link";},2500);}});}function phEmbed(){var runId=window.location.pathname.split("/").pop().replace(".html","");var embedUrl="https://pantherahive.com/embed/"+runId;var code='';navigator.clipboard.writeText(code).then(function(){var el=document.getElementById("ph-embed-lbl");if(el){el.textContent="Embed code copied!";setTimeout(function(){el.textContent="Get Embed Code";},2500);}});}