-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_with_github_cli.sh
More file actions
executable file
·377 lines (312 loc) · 8.47 KB
/
Copy pathupload_with_github_cli.sh
File metadata and controls
executable file
·377 lines (312 loc) · 8.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#!/bin/bash
# Script para upload do projeto usando GitHub CLI
# Barramento MCPs v2.0 - Integração Direta
set -e
# Cores para output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Função para log
log() {
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
}
success() {
echo -e "${GREEN}✅ $1${NC}"
}
warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
error() {
echo -e "${RED}❌ $1${NC}"
}
# Verificar parâmetros
if [ $# -lt 1 ]; then
error "Uso: $0 <nome-do-repositorio> [descricao] [privado]"
echo "Exemplo: $0 barramento-mcps-v2 'Barramento de MCPs v2.0' false"
exit 1
fi
REPO_NAME="$1"
DESCRIPTION="${2:-Barramento de MCPs v2.0 - Sistema completo de gerenciamento de MCPs}"
PRIVATE="${3:-false}"
log "🚀 Iniciando upload do projeto usando GitHub CLI..."
log "📁 Repositório: $REPO_NAME"
log "📝 Descrição: $DESCRIPTION"
log "🔒 Privado: $PRIVATE"
# Verificar se GitHub CLI está instalado e logado
if ! command -v gh &> /dev/null; then
error "GitHub CLI não está instalado. Instale com: brew install gh"
exit 1
fi
# Verificar se está logado
if ! gh auth status &> /dev/null; then
error "Não está logado no GitHub CLI. Execute: gh auth login"
exit 1
fi
# Obter informações do usuário
USERNAME=$(gh api user --jq .login)
log "👤 Usuário GitHub: $USERNAME"
# Obter diretório do projeto
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
log "📂 Diretório do projeto: $PROJECT_DIR"
# Verificar se já é um repositório Git
if [ -d "$PROJECT_DIR/.git" ]; then
warning "Repositório Git já existe. Continuando..."
else
log "🔧 Inicializando repositório Git..."
cd "$PROJECT_DIR"
git init
git config user.name "$USERNAME"
git config user.email "$USERNAME@users.noreply.github.com"
success "Repositório Git inicializado"
fi
# Criar .gitignore se não existir
if [ ! -f "$PROJECT_DIR/.gitignore" ]; then
log "📝 Criando .gitignore..."
cat > "$PROJECT_DIR/.gitignore" << 'EOF'
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# Virtual environments
venv/
env/
ENV/
env.bak/
venv.bak/
venv_pdf/
# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Logs
*.log
logs/
log/
# Temporary files
*.tmp
*.temp
temp/
tmp/
# Docker
.dockerignore
# MCP specific
_download/
_transcisao/
verificados/
*.pdf
!docs/**/*.pdf
# Environment variables
.env
.env.local
.env.production
.env.staging
# Coverage reports
htmlcov/
.coverage
.coverage.*
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# Secrets
secrets/
*.pem
*.key
config.env
EOF
success ".gitignore criado"
fi
# Criar README.md se não existir
if [ ! -f "$PROJECT_DIR/README.md" ]; then
log "📝 Criando README.md..."
cat > "$PROJECT_DIR/README.md" << EOF
# 🚀 Barramento de MCPs v2.0 - $REPO_NAME
**Status:** ✅ Produção
**Versão:** 2.0.0
**Data:** $(date +'%d/%m/%Y')
## 🎯 Visão Geral
Este é o **Barramento de Modelos de Comportamento de Prompt (MCPs) v2.0**, uma arquitetura completa para gerenciamento e orquestração de múltiplos MCPs com observabilidade nativa, governança GitOps e deployment automatizado.
## ✨ Funcionalidades
### 🔧 **MCPs Implementados**
- 🌊 **Ocean PDF Scraper** - Scraping inteligente de PDFs
- 📄 **PDF Processor** - Processamento e extração de texto
- 🌐 **Web Scraper** - Scraping web genérico
- 📝 **Markdown Processor** - Processamento de Markdown
- ✅ **Data Validator** - Validação de dados
- 🐙 **GitHub Integration** - Integração completa com GitHub
### 🏗️ **Arquitetura v2.0**
- ✅ **Observabilidade Nativa** - Prometheus + Grafana
- ✅ **Governança GitOps** - Políticas como código
- ✅ **Testes Automatizados** - Framework completo
- ✅ **Deploy Inteligente** - Pipeline automatizado
- ✅ **Template Padrão** - Para novos MCPs
## 🚀 Como Usar
### 1. **Iniciar o Barramento**
\`\`\`bash
# Usar Docker Compose
docker-compose -f config/docker/docker-compose-v2.yml up -d
# Ou usar script de deploy
./scripts/deploy-v2.sh deploy
\`\`\`
### 2. **Usar Ocean PDF Scraper**
\`\`\`bash
# Baixar livros de Data Science
curl -X POST "http://localhost:8094/workflow/ocean_pdf" \\
-H "Content-Type: application/json" \\
-d '{"keyword": "machine learning", "max_downloads": 10}'
\`\`\`
### 3. **Integração GitHub**
\`\`\`bash
# Listar repositórios
curl "http://localhost:8009/repositories/seu-usuario"
# Sincronizar MCPs
curl "http://localhost:8009/workflow/mcp-sync"
\`\`\`
## 📊 Monitoramento
### 🌐 **URLs dos Serviços**
- **Gateway Kong**: http://localhost:8000
- **Ocean PDF Scraper**: http://localhost:8094
- **GitHub Integration**: http://localhost:8009
- **Prometheus**: http://localhost:9090
- **Grafana**: http://localhost:3000
---
**🚀 Barramento MCPs v2.0 - Produzindo resultados desde 2024!**
EOF
success "README.md criado"
fi
# Criar workflow GitHub Actions
log "⚙️ Criando workflow GitHub Actions..."
mkdir -p "$PROJECT_DIR/.github/workflows"
cat > "$PROJECT_DIR/.github/workflows/ci-cd.yml" << 'EOF'
name: CI/CD - Barramento MCPs v2.0
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
PYTHON_VERSION: '3.11'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
service: [ocean-pdf-scraper, pdf-processor, web-scraper, markdown-processor, data-validator, github-integration]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
cd src/mcp-servers/${{ matrix.service }}
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run tests
run: |
cd src/mcp-servers/${{ matrix.service }}
pytest tests/ -v --cov=. --cov-report=xml
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to production
run: |
echo "🚀 Deploying Barramento MCPs v2.0 to production..."
echo "✅ All services built and ready for deployment"
EOF
success "Workflow GitHub Actions criado"
# Adicionar arquivos ao Git
log "📁 Adicionando arquivos ao Git..."
cd "$PROJECT_DIR"
git add .
# Verificar se há arquivos para commit
if git diff --staged --quiet; then
warning "Nenhum arquivo novo para commit"
else
# Fazer commit
log "💾 Fazendo commit..."
git commit -m "🚀 Upload inicial do Barramento MCPs v2.0 - $(date +'%d/%m/%Y %H:%M')"
success "Commit realizado"
fi
# Criar repositório no GitHub usando GitHub CLI
log "🌐 Criando repositório no GitHub usando GitHub CLI..."
# Verificar se repositório já existe
if gh repo view "$USERNAME/$REPO_NAME" &> /dev/null; then
warning "Repositório $USERNAME/$REPO_NAME já existe"
read -p "Deseja continuar e fazer push? (Y/n): " continue_push
if [[ $continue_push =~ ^[Nn]$ ]]; then
error "Operação cancelada"
exit 1
fi
else
# Criar repositório
if [ "$PRIVATE" = "true" ]; then
gh repo create "$REPO_NAME" --private --description "$DESCRIPTION" --source=. --remote=origin --push
else
gh repo create "$REPO_NAME" --public --description "$DESCRIPTION" --source=. --remote=origin --push
fi
success "Repositório criado no GitHub"
fi
# Fazer push se necessário
log "🌐 Fazendo push para GitHub..."
git push -u origin main
success "Push realizado com sucesso!"
# Mostrar informações finais
echo ""
success "🎉 Projeto enviado para GitHub com sucesso!"
echo ""
echo "📊 Informações do repositório:"
echo " 🌐 URL: https://github.com/$USERNAME/$REPO_NAME"
echo " 📁 Clone: https://github.com/$USERNAME/$REPO_NAME.git"
echo " 📝 Descrição: $DESCRIPTION"
echo " 🔒 Privado: $PRIVATE"
echo ""
echo "🚀 Próximos passos:"
echo " 1. Acesse: https://github.com/$USERNAME/$REPO_NAME"
echo " 2. Configure GitHub Actions se necessário"
echo " 3. Adicione colaboradores se necessário"
echo " 4. Configure webhooks para integração contínua"
echo ""
log "Upload concluído usando GitHub CLI! 🎉"