Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next"
}
137 changes: 137 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# GitHub Actions and CI/CD Setup

This repository is now configured with automated GitHub Actions workflows for continuous integration and deployment.

## πŸš€ Workflows

### 1. CI/CD Pipeline (`.github/workflows/ci.yml`)
- **Triggers**: Push to `main`/`develop`, Pull Requests to `main`
- **Jobs**:
- Tests on Node.js 18.x and 20.x
- ESLint code quality checks
- TypeScript compilation
- Performance validation
- Build verification
- Automatic deployment to Firebase App Hosting (main branch only)

### 2. Production Deployment (`.github/workflows/deploy.yml`)
- **Triggers**: Release published, Manual dispatch
- **Features**:
- Production-ready build validation
- Firebase App Hosting deployment
- Build artifacts verification
- Deployment notifications

### 3. Pull Request Validation (`.github/workflows/pr-validation.yml`)
- **Triggers**: PR opened/updated to `main`/`develop`
- **Features**:
- Code quality checks
- Performance validation
- Bundle size analysis
- Security audit
- Lighthouse performance testing
- Automated PR comments with results

## πŸ”§ Required Secrets

Configure these secrets in your GitHub repository settings:

### Firebase Deployment
```
FIREBASE_SERVICE_ACCOUNT # Firebase service account JSON
FIREBASE_PROJECT_ID # Your Firebase project ID
FIREBASE_TOKEN # Firebase CI token
```

### Application Secrets
```
SENDGRID_API_KEY # SendGrid API key for contact form
LHCI_GITHUB_APP_TOKEN # Lighthouse CI GitHub app token (optional)
```

## πŸ“‹ Setup Instructions

### 1. Firebase Setup
```bash
# Install Firebase CLI
npm install -g firebase-tools

# Login to Firebase
firebase login

# Initialize project (if not already done)
firebase init hosting

# Get deployment token for CI
firebase login:ci
```

### 2. Repository Secrets
1. Go to Repository Settings β†’ Secrets and Variables β†’ Actions
2. Add the required secrets listed above
3. For `FIREBASE_SERVICE_ACCOUNT`:
- Go to Firebase Console β†’ Project Settings β†’ Service Accounts
- Generate new private key
- Copy the entire JSON content as the secret value

### 3. Environment Configuration
The workflows use these environment variables:
- `NEXT_PUBLIC_SITE_URL`: Site URL (https://kodegas.com)
- `NODE_ENV`: Environment (production/development)
- `SENDGRID_API_KEY`: Email service configuration

## πŸ” Monitoring

### Build Status
- Check the Actions tab in your GitHub repository
- Green checkmarks indicate successful workflows
- Red X marks indicate failures with detailed logs

### Performance Monitoring
- Lighthouse CI runs on every PR
- Performance validation script ensures all optimizations are working
- Bundle size analysis helps track application growth

### Error Handling
- Workflows include error handling and notifications
- Failed deployments don't affect the live site
- Rollback capabilities through Firebase Console

## πŸ›  Troubleshooting

### Common Issues

1. **Build Failures**
- Check Node.js version compatibility
- Verify all dependencies are installed
- Review TypeScript compilation errors

2. **Deployment Failures**
- Verify Firebase project configuration
- Check service account permissions
- Ensure deployment token is valid

3. **Performance Issues**
- Review Lighthouse CI reports
- Check bundle size increases
- Validate performance optimization features

### Manual Deployment
If automated deployment fails, you can deploy manually:
```bash
npm run build
firebase deploy
```

## πŸ“ˆ Performance Features Validated

The CI/CD pipeline automatically validates these performance optimizations:
- βœ… Error Boundary implementation
- βœ… Performance Observer error handling
- βœ… Resource loading optimization
- βœ… Chunk loading error recovery
- βœ… Error tracking and analytics
- βœ… Bundle optimization
- βœ… Component integration

All workflows ensure these performance features continue working correctly with every code change.
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI/CD Pipeline

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

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

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

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint --if-present
continue-on-error: true # Allow build to continue even if linting fails

- name: Run type checking
run: npm run typecheck --if-present
continue-on-error: true # Allow build to continue even if type checking fails

- name: Run performance validation
run: node validate-performance-fixes.js

- name: Build application
run: npm run build
env:
NEXT_PUBLIC_SITE_URL: https://kodegas.com

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-files-${{ matrix.node-version }}
path: .next/
retention-days: 1

deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

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

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build for production
run: npm run build
env:
NEXT_PUBLIC_SITE_URL: https://kodegas.com
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-files-20.x

- name: Setup Firebase CLI
uses: google-github-actions/setup-gcloud@v2
with:
service_account_key: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
project_id: ${{ secrets.FIREBASE_PROJECT_ID }}

- name: Install Firebase CLI
run: npm install -g firebase-tools

- name: Deploy to Firebase App Hosting
run: firebase deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
88 changes: 88 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Deploy to Production

on:
release:
types: [published]
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'production'
type: choice
options:
- production
- staging

jobs:
deploy-production:
runs-on: ubuntu-latest
environment: production

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

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run performance validation
run: node validate-performance-fixes.js

- name: Build for production
run: npm run build
env:
NEXT_PUBLIC_SITE_URL: https://kodegas.com
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
NODE_ENV: production

- name: Run production tests
run: |
echo "Running production readiness checks..."
# Check if build directory exists
if [ ! -d ".next" ]; then
echo "Build failed - .next directory not found"
exit 1
fi

# Check for critical files
if [ ! -f ".next/BUILD_ID" ]; then
echo "Build incomplete - BUILD_ID not found"
exit 1
fi

echo "Production build validated successfully"

- name: Setup Firebase CLI
uses: google-github-actions/setup-gcloud@v2
with:
service_account_key: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
project_id: ${{ secrets.FIREBASE_PROJECT_ID }}

- name: Install Firebase CLI
run: npm install -g firebase-tools

- name: Deploy to Firebase App Hosting
run: |
echo "Deploying to Firebase App Hosting..."
firebase deploy --project ${{ secrets.FIREBASE_PROJECT_ID }}
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

- name: Deploy notification
if: success()
run: |
echo "πŸš€ Deployment successful!"
echo "Site URL: https://kodegas.com"

- name: Deploy failure notification
if: failure()
run: |
echo "❌ Deployment failed!"
echo "Check the logs above for details."
Loading
Loading