Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Este PR implementa la **solución completa para el problema de crashes de Railwa

### 🎯 **Problema Solucionado**
- ❌ **Problema**: Aplicación crashes en Railway después de exactamente 2 minutos
- ❌ **Problema**: Botones y funcionalidades del admin dashboard no operativas
- ❌ **Problema**: Botones y funcionalidades del admin dashboard no operativas
- ❌ **Problema**: Templates genéricos en lugar de específicos
- ❌ **Problema**: Configuración de despliegue incompleta

Expand Down Expand Up @@ -88,7 +88,7 @@ Este PR implementa la **solución completa para el problema de crashes de Railwa
- [ ] Variables de entorno configuradas en Railway
- [ ] `RAILWAY_TOKEN` configurado en GitHub Secrets

### **Post-merge Actions**
### **Post-merge Actions**
1. **Auto-deploy** se activará automáticamente en `main`
2. **Health check** validará despliegue exitoso
3. **Monitoring** confirmará estabilidad post-deploy
Expand Down Expand Up @@ -134,4 +134,4 @@ Este PR implementa la **solución completa para el problema de crashes de Railwa

---

**🎉 Este PR convierte NeuroBank FastAPI en una aplicación bancaria de nivel empresarial con despliegue automático y funcionalidad completa!**
**🎉 Este PR convierte NeuroBank FastAPI en una aplicación bancaria de nivel empresarial con despliegue automático y funcionalidad completa!**
44 changes: 22 additions & 22 deletions .github/workflows/ci-cd-fixed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ jobs:
if: github.event.inputs.skip_tests != 'true'
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests with coverage
run: |
python -m pytest --cov=app --cov-report=xml --cov-report=html

- name: Upload coverage reports
uses: actions/upload-artifact@v4
if: always()
Expand All @@ -67,27 +67,27 @@ jobs:
if: github.event.inputs.skip_tests != 'true'
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install bandit safety

- name: Run Bandit security scan
run: |
bandit -r app/ -f json -o bandit-report.json --skip B101 || true

- name: Run Safety vulnerability scan
run: |
pip freeze > current-requirements.txt
safety scan --json --output safety-report.json --continue-on-error || true

- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
Expand All @@ -101,15 +101,15 @@ jobs:
needs: [test, security]
runs-on: ubuntu-latest
if: |
always() &&
always() &&
github.event.inputs.force_deploy == 'true' &&
(github.event.inputs.skip_tests == 'true' ||
(github.event.inputs.skip_tests == 'true' ||
(needs.test.result == 'success' && needs.security.result == 'success'))

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

- name: Emergency deployment warning
if: github.event.inputs.skip_tests == 'true'
run: |
Expand All @@ -119,39 +119,39 @@ jobs:
echo "🚨 This should only be used in emergency situations!"
echo "🚨 Make sure to run full testing after deployment!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
role-session-name: GitHubActions-Fixed-${{ github.run_id }}

- name: Verify AWS connection
run: |
echo "🔍 Verifying AWS OIDC connection..."
aws sts get-caller-identity
echo "✅ AWS connection verified!"

- name: Setup SAM CLI
uses: aws-actions/setup-sam@v2
with:
use-installer: true

- name: Create ECR repository if not exists
run: |
aws ecr describe-repositories --repository-names ${{ env.ECR_REPOSITORY }} --region ${{ env.AWS_REGION }} || \
aws ecr create-repository --repository-name ${{ env.ECR_REPOSITORY }} --region ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and push Docker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
Expand All @@ -161,7 +161,7 @@ jobs:
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest

- name: Deploy to AWS Lambda
run: |
sam build --region ${{ env.AWS_REGION }}
Expand All @@ -170,4 +170,4 @@ jobs:
--capabilities CAPABILITY_IAM \
--region ${{ env.AWS_REGION }} \
--parameter-overrides ApiKey=${{ secrets.API_KEY || 'emergency-deploy-key' }}
echo "🎉 Emergency deployment completed!"
echo "🎉 Emergency deployment completed!"
64 changes: 32 additions & 32 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,30 @@ env:
jobs:
test:
runs-on: ubuntu-latest

# ✅ Variables de entorno para tests
env:
API_KEY: "NeuroBankDemo2025-SecureKey-ForTestingOnly"
ENVIRONMENT: "testing"
CI: "true"

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests with coverage
run: |
python -m pytest --cov=app --cov-report=xml --cov-report=html

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: always()
Expand All @@ -71,40 +71,40 @@ jobs:

security:
runs-on: ubuntu-latest

# ✅ Variables de entorno para security checks
env:
API_KEY: "NeuroBankDemo2025-SecureKey-ForTestingOnly"
ENVIRONMENT: "testing"
CI: "true"

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Install security tools
run: pip install bandit safety pytest-cov

- name: Run Bandit (exclude tests from assert checking)
run: |
bandit -r app/ -f json -o bandit-report.json --skip B101 || true
echo "Bandit scan completed - check bandit-report.json for details"

- name: Run Safety scan
run: |
pip freeze > current-requirements.txt
safety scan --json --output safety-report.json --continue-on-error || true
echo "Safety scan completed - check safety-report.json for details"

- name: Upload security reports as artifacts
uses: actions/upload-artifact@v4
if: always()
Expand All @@ -118,7 +118,7 @@ jobs:
needs: [test, security]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

steps:
- name: Check deployment readiness
run: |
Expand Down Expand Up @@ -157,30 +157,30 @@ jobs:
runs-on: ubuntu-latest
# Solo deployar cuando el usuario lo active manualmente con workflow_dispatch
if: |
(github.event_name == 'workflow_dispatch' &&
github.event.inputs.deploy_to_aws == 'true' &&
(github.event_name == 'workflow_dispatch' &&
github.event.inputs.deploy_to_aws == 'true' &&
github.ref == 'refs/heads/main')

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

- name: Verify OIDC prerequisites
run: |
echo "🚀 Starting OIDC-secured deployment process..."
echo "📍 AWS Region: ${{ env.AWS_REGION }}"
echo "📦 ECR Repository: ${{ env.ECR_REPOSITORY }}"
develop
echo "🔑 Checking AWS Credentials..."

# Verify secrets are available (without exposing them)
if [ -z "${{ secrets.AWS_ACCESS_KEY_ID }}" ]; then
echo "❌ AWS_ACCESS_KEY_ID is missing"
exit 1
else
echo "✅ AWS_ACCESS_KEY_ID is available"
fi

if [ -z "${{ secrets.AWS_SECRET_ACCESS_KEY }}" ]; then
echo "❌ AWS_SECRET_ACCESS_KEY is missing"
exit 1
Expand All @@ -189,7 +189,7 @@ jobs:

echo "� AWS Role ARN: ${{ env.AWS_ROLE_ARN }}"
echo "🏗️ Using secure OIDC authentication ✨"

# Verify AWS Account ID is available
if [ -z "${{ secrets.AWS_ACCOUNT_ID }}" ]; then
echo "❌ AWS_ACCOUNT_ID secret is missing"
Expand All @@ -199,7 +199,7 @@ jobs:
echo "✅ AWS_ACCOUNT_ID is configured"
main
fi

if [ -z "${{ secrets.API_KEY }}" ]; then
echo "⚠️ API_KEY is missing - using default"
else
Expand All @@ -209,47 +209,47 @@ jobs:
echo "✅ API_KEY is configured"
main
fi

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
role-session-name: GitHubActions-${{ github.run_id }}

- name: Debug AWS identity
run: |
echo "🧪 Testing AWS OIDC connection..."
aws sts get-caller-identity
echo "✅ AWS OIDC connection successful!"

- name: Test AWS connection
run: |
echo "🧪 Testing AWS connection..."
aws sts get-caller-identity
echo "✅ AWS connection successful!"

- name: Setup SAM CLI
uses: aws-actions/setup-sam@v2
with:
use-installer: true

- name: Create ECR repository if not exists
run: |
echo "📦 Ensuring ECR repository exists..."
aws ecr describe-repositories --repository-names ${{ env.ECR_REPOSITORY }} --region ${{ env.AWS_REGION }} || \
aws ecr create-repository --repository-name ${{ env.ECR_REPOSITORY }} --region ${{ env.AWS_REGION }}
echo "✅ ECR repository ready"

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
Expand All @@ -262,7 +262,7 @@ jobs:
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "✅ Docker image pushed successfully!"

- name: Deploy to AWS Lambda
run: |
echo "🚀 Starting SAM deployment..."
Expand Down
Loading
Loading