#!/usr/bin/env bash
set -euo pipefail

GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEMPLATES_DIR="${SCRIPT_DIR}/../templates"

echo -e "${BLUE}=== GitHub Actions Workflow Generator ===${NC}\n"

echo "Select workflow type:"
echo "  1) Node.js CI"
echo "  2) Python CI"
echo "  3) Security Scanning"
echo "  4) Docker Build & Push"
echo

read -rp "Choice [1-4]: " choice

mkdir -p .github/workflows

case $choice in
    1)
        cp "$TEMPLATES_DIR/ci/node-ci.yml" .github/workflows/ci.yml
        echo -e "${GREEN}✓ Node.js CI workflow created${NC}"
        ;;
    2)
        cp "$TEMPLATES_DIR/ci/python-ci.yml" .github/workflows/ci.yml
        echo -e "${GREEN}✓ Python CI workflow created${NC}"
        ;;
    3)
        cp "$TEMPLATES_DIR/security/security-scan.yml" .github/workflows/security.yml
        echo -e "${GREEN}✓ Security scanning workflow created${NC}"
        ;;
    4)
        cp "$TEMPLATES_DIR/cd/deploy-docker.yml" .github/workflows/deploy.yml
        echo -e "${GREEN}✓ Docker deployment workflow created${NC}"
        ;;
esac

echo -e "\n${BLUE}Next: Commit and push to trigger workflow${NC}"
