Merge development into main #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: π Deploy - Standard Production Deployment | |
| on: | |
| push: | |
| branches: [main, release/*] | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| inputs: | |
| deployment_type: | |
| description: 'Deployment Type' | |
| required: true | |
| default: 'staging' | |
| type: choice | |
| options: | |
| - 'staging' | |
| - 'production' | |
| user_percentage: | |
| description: 'User Rollout Percentage (1-100)' | |
| required: false | |
| default: '10' | |
| type: string | |
| skip_healthcare_validation: | |
| description: 'Skip Healthcare Validation (DANGEROUS - Use only for hotfixes)' | |
| required: false | |
| default: false | |
| type: boolean | |
| env: | |
| EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} | |
| NODE_VERSION: '20' | |
| HEALTHCARE_COMPLIANCE: 'true' | |
| NEW_ARCHITECTURE: 'true' | |
| CLINICAL_VALIDATION: 'true' | |
| jobs: | |
| # Healthcare Validation Gate - REQUIRED for all deployments | |
| healthcare-validation-gate: | |
| name: π₯ Healthcare Validation Gate | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| outputs: | |
| crisis-validated: ${{ steps.crisis-gate.outputs.validated }} | |
| clinical-validated: ${{ steps.clinical-gate.outputs.validated }} | |
| compliance-validated: ${{ steps.compliance-gate.outputs.validated }} | |
| deployment-approved: ${{ steps.final-gate.outputs.approved }} | |
| steps: | |
| - name: π Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: π¦ Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: 'app/package-lock.json' | |
| - name: π₯ Install Dependencies | |
| run: | | |
| cd app | |
| npm ci --prefer-offline --no-audit | |
| - name: π¨ Crisis Authority Gate | |
| id: crisis-gate | |
| run: | | |
| cd app | |
| echo "π¨ HEALTHCARE GATE: Crisis Authority Validation" | |
| if [ "${{ github.event.inputs.skip_healthcare_validation }}" == "true" ]; then | |
| echo "β οΈ WARNING: Healthcare validation skipped - EMERGENCY MODE" | |
| echo "validated=skipped" >> $GITHUB_OUTPUT | |
| else | |
| echo "π¨ Validating Crisis Response Systems..." | |
| npm run validate:crisis-authority | |
| npm run test:crisis -- --ci --testNamePattern="Crisis.*Response.*Time" --testTimeout=10000 | |
| echo "validated=true" >> $GITHUB_OUTPUT | |
| echo "β Crisis Authority: VALIDATED" | |
| fi | |
| - name: π©Ί Clinical Authority Gate | |
| id: clinical-gate | |
| run: | | |
| cd app | |
| echo "π©Ί HEALTHCARE GATE: Clinical Authority Validation" | |
| if [ "${{ github.event.inputs.skip_healthcare_validation }}" == "true" ]; then | |
| echo "β οΈ WARNING: Healthcare validation skipped - EMERGENCY MODE" | |
| echo "validated=skipped" >> $GITHUB_OUTPUT | |
| else | |
| echo "π©Ί Validating Clinical Accuracy Systems..." | |
| npm run validate:clinical-authority | |
| npm run test:clinical -- --ci --testNamePattern="PHQ.*GAD.*Accuracy" --testTimeout=15000 | |
| echo "validated=true" >> $GITHUB_OUTPUT | |
| echo "β Clinical Authority: VALIDATED" | |
| fi | |
| - name: π Compliance Authority Gate | |
| id: compliance-gate | |
| run: | | |
| cd app | |
| echo "π HEALTHCARE GATE: Compliance Authority Validation" | |
| if [ "${{ github.event.inputs.skip_healthcare_validation }}" == "true" ]; then | |
| echo "β οΈ WARNING: Healthcare validation skipped - EMERGENCY MODE" | |
| echo "validated=skipped" >> $GITHUB_OUTPUT | |
| else | |
| echo "π Validating HIPAA & Data Privacy..." | |
| npm run validate:compliance-authority | |
| npm run test:security -- --ci --testNamePattern="HIPAA.*Compliance" --testTimeout=10000 | |
| echo "validated=true" >> $GITHUB_OUTPUT | |
| echo "β Compliance Authority: VALIDATED" | |
| fi | |
| - name: π₯ Final Healthcare Gate Decision | |
| id: final-gate | |
| run: | | |
| crisis="${{ steps.crisis-gate.outputs.validated }}" | |
| clinical="${{ steps.clinical-gate.outputs.validated }}" | |
| compliance="${{ steps.compliance-gate.outputs.validated }}" | |
| echo "π₯ Healthcare Gate Summary:" | |
| echo "Crisis: $crisis" | |
| echo "Clinical: $clinical" | |
| echo "Compliance: $compliance" | |
| if [ "$crisis" == "true" ] && [ "$clinical" == "true" ] && [ "$compliance" == "true" ]; then | |
| echo "β HEALTHCARE DEPLOYMENT APPROVED" | |
| echo "approved=true" >> $GITHUB_OUTPUT | |
| elif [ "$crisis" == "skipped" ] || [ "$clinical" == "skipped" ] || [ "$compliance" == "skipped" ]; then | |
| echo "β οΈ EMERGENCY DEPLOYMENT APPROVED (Healthcare validation skipped)" | |
| echo "approved=emergency" >> $GITHUB_OUTPUT | |
| else | |
| echo "β HEALTHCARE DEPLOYMENT BLOCKED" | |
| echo "approved=false" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| - name: π Upload Healthcare Gate Report | |
| uses: actions/upload-artifact@v3 | |
| if: always() | |
| with: | |
| name: healthcare-gate-report | |
| path: | | |
| app/coverage/ | |
| app/__tests__/reports/ | |
| retention-days: 90 | |
| # Pre-Build Validation | |
| pre-build-validation: | |
| name: π Pre-Build Validation | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| needs: healthcare-validation-gate | |
| if: needs.healthcare-validation-gate.outputs.deployment-approved == 'true' || needs.healthcare-validation-gate.outputs.deployment-approved == 'emergency' | |
| steps: | |
| - name: π Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: π¦ Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: 'app/package-lock.json' | |
| - name: π₯ Install Dependencies | |
| run: | | |
| cd app | |
| npm ci --prefer-offline --no-audit | |
| - name: π₯ Production Readiness Validation | |
| run: | | |
| cd app | |
| echo "π₯ Validating production readiness..." | |
| npm run validate:production-readiness | |
| echo "β Production readiness validated" | |
| - name: π New Architecture Pre-Build Check | |
| run: | | |
| cd app | |
| echo "π Validating New Architecture configuration..." | |
| npm run perf:new-arch-quick | |
| echo "β New Architecture validated for production build" | |
| - name: π Security Pre-Build Validation | |
| run: | | |
| cd app | |
| echo "π Security validation before build..." | |
| npm run validate:security-critical | |
| npm audit --audit-level=moderate | |
| echo "β Security validation passed" | |
| - name: βΏ Accessibility Pre-Build Validation | |
| run: | | |
| cd app | |
| echo "βΏ Accessibility validation before build..." | |
| npm run validate:accessibility | |
| echo "β Accessibility validation passed" | |
| # Production Build & Deployment | |
| production-build: | |
| name: ποΈ Production Build & Deploy | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| needs: [healthcare-validation-gate, pre-build-validation] | |
| if: success() | |
| strategy: | |
| matrix: | |
| platform: [ios, android] | |
| steps: | |
| - name: π Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: π¦ Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: 'app/package-lock.json' | |
| - name: π§ Setup EAS CLI | |
| uses: expo/expo-github-action@v8 | |
| with: | |
| expo-version: latest | |
| eas-version: latest | |
| token: ${{ secrets.EXPO_TOKEN }} | |
| - name: π₯ Install Dependencies | |
| run: | | |
| cd app | |
| npm ci --prefer-offline --no-audit | |
| - name: π₯ Final Healthcare Validation Before Build | |
| run: | | |
| cd app | |
| echo "π₯ Final healthcare validation before build..." | |
| if [ "${{ needs.healthcare-validation-gate.outputs.deployment-approved }}" == "emergency" ]; then | |
| echo "β οΈ EMERGENCY BUILD - Healthcare validation was skipped" | |
| else | |
| echo "β Healthcare compliance validated - proceeding with build" | |
| fi | |
| - name: ποΈ Build Application | |
| run: | | |
| cd app | |
| if [ "${{ github.event.inputs.deployment_type }}" == "staging" ]; then | |
| echo "π§ͺ Building for staging environment..." | |
| eas build --platform ${{ matrix.platform }} --profile staging --non-interactive | |
| else | |
| echo "π Building for production environment..." | |
| eas build --platform ${{ matrix.platform }} --profile production --non-interactive | |
| fi | |
| - name: π Upload Build Artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: build-artifacts-${{ matrix.platform }} | |
| path: | | |
| app/dist/ | |
| app/build-logs/ | |
| retention-days: 90 | |
| # Deployment to Cloud Infrastructure | |
| cloud-deployment: | |
| name: βοΈ Cloud Infrastructure Deployment | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: production-build | |
| if: success() | |
| steps: | |
| - name: π Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: π¦ Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: 'app/package-lock.json' | |
| - name: π₯ Install Dependencies | |
| run: | | |
| cd app | |
| npm ci --prefer-offline --no-audit | |
| - name: βοΈ Deploy to Supabase Cloud | |
| env: | |
| SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }} | |
| SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }} | |
| run: | | |
| cd app | |
| echo "βοΈ Deploying to Supabase cloud infrastructure..." | |
| npm run deploy:supabase-cloud | |
| echo "β Cloud infrastructure deployment completed" | |
| - name: ποΈ Database Migration Validation | |
| env: | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| run: | | |
| cd app | |
| echo "ποΈ Validating database migrations..." | |
| npm run db:migrate:validate | |
| echo "β Database migrations validated" | |
| - name: π Cloud Security Validation | |
| run: | | |
| cd app | |
| echo "π Validating cloud security configuration..." | |
| npm run validate:cloud-security | |
| echo "β Cloud security validated" | |
| # App Store Submission (Production Only) | |
| app-store-submission: | |
| name: πͺ App Store Submission | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: [production-build, cloud-deployment] | |
| if: | | |
| success() && | |
| ((startsWith(github.ref, 'refs/tags/v')) || | |
| (github.event.inputs.deployment_type == 'production')) | |
| strategy: | |
| matrix: | |
| platform: [ios, android] | |
| steps: | |
| - name: π Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: π§ Setup EAS CLI | |
| uses: expo/expo-github-action@v8 | |
| with: | |
| expo-version: latest | |
| eas-version: latest | |
| token: ${{ secrets.EXPO_TOKEN }} | |
| - name: πͺ Submit to App Store | |
| run: | | |
| cd app | |
| echo "πͺ Submitting to ${{ matrix.platform }} app store..." | |
| if [ "${{ matrix.platform }}" == "ios" ]; then | |
| echo "π iOS App Store submission..." | |
| eas submit --platform ios --profile production --non-interactive | |
| else | |
| echo "π€ Google Play Store submission..." | |
| eas submit --platform android --profile production --non-interactive | |
| fi | |
| - name: π App Store Submission Report | |
| run: | | |
| echo "πͺ App Store Submission Summary:" > app-store-report-${{ matrix.platform }}.md | |
| echo "- Platform: ${{ matrix.platform }}" >> app-store-report-${{ matrix.platform }}.md | |
| echo "- Submission Time: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> app-store-report-${{ matrix.platform }}.md | |
| echo "- Healthcare Validation: ${{ needs.healthcare-validation-gate.outputs.deployment-approved }}" >> app-store-report-${{ matrix.platform }}.md | |
| - name: π Upload App Store Report | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: app-store-report-${{ matrix.platform }} | |
| path: app-store-report-${{ matrix.platform }}.md | |
| retention-days: 365 | |
| # Post-Deployment Validation | |
| post-deployment-validation: | |
| name: β Post-Deployment Validation | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| needs: [healthcare-validation-gate, production-build, cloud-deployment] | |
| if: success() | |
| steps: | |
| - name: π Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: π¦ Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: 'app/package-lock.json' | |
| - name: π₯ Install Dependencies | |
| run: | | |
| cd app | |
| npm ci --prefer-offline --no-audit | |
| - name: π₯ Post-Deployment Healthcare Validation | |
| run: | | |
| cd app | |
| echo "π₯ Validating healthcare services post-deployment..." | |
| npm run test:crisis -- --testNamePattern="Crisis.*Integration" --ci | |
| npm run test:clinical -- --testNamePattern="Clinical.*Integration" --ci | |
| echo "β Healthcare services validated post-deployment" | |
| - name: π New Architecture Benefits Validation | |
| run: | | |
| cd app | |
| echo "π Validating New Architecture benefits post-deployment..." | |
| npm run test:new-arch-comprehensive -- --ci | |
| echo "β New Architecture benefits confirmed" | |
| - name: π Security & Compliance Post-Deployment Check | |
| run: | | |
| cd app | |
| echo "π Post-deployment security & compliance check..." | |
| npm run validate:post-deployment-security | |
| echo "β Security & compliance validated post-deployment" | |
| - name: π Performance Metrics Validation | |
| run: | | |
| cd app | |
| echo "π Validating performance metrics..." | |
| npm run perf:validate-post-deployment | |
| echo "β Performance metrics validated" | |
| # Deployment Report Generation | |
| deployment-report: | |
| name: π Deployment Report | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| needs: [healthcare-validation-gate, production-build, cloud-deployment, post-deployment-validation] | |
| if: always() | |
| steps: | |
| - name: π Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: π Generate Deployment Report | |
| run: | | |
| echo "# π Standard Deployment Report - FullMind MBCT" > deployment-report.md | |
| echo "" >> deployment-report.md | |
| echo "## Deployment Summary" >> deployment-report.md | |
| echo "- **Deployment Type**: ${{ github.event.inputs.deployment_type || 'production' }}" >> deployment-report.md | |
| echo "- **Deployment Time**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> deployment-report.md | |
| echo "- **Git Commit**: ${{ github.sha }}" >> deployment-report.md | |
| echo "- **Healthcare Validation**: ${{ needs.healthcare-validation-gate.outputs.deployment-approved }}" >> deployment-report.md | |
| echo "" >> deployment-report.md | |
| echo "## Healthcare Authority Validation" >> deployment-report.md | |
| echo "- **Crisis Authority**: ${{ needs.healthcare-validation-gate.outputs.crisis-validated }}" >> deployment-report.md | |
| echo "- **Clinical Authority**: ${{ needs.healthcare-validation-gate.outputs.clinical-validated }}" >> deployment-report.md | |
| echo "- **Compliance Authority**: ${{ needs.healthcare-validation-gate.outputs.compliance-validated }}" >> deployment-report.md | |
| echo "" >> deployment-report.md | |
| echo "## Deployment Results" >> deployment-report.md | |
| echo "- **Production Build**: ${{ needs.production-build.result }}" >> deployment-report.md | |
| echo "- **Cloud Deployment**: ${{ needs.cloud-deployment.result }}" >> deployment-report.md | |
| echo "- **Post-Deployment Validation**: ${{ needs.post-deployment-validation.result }}" >> deployment-report.md | |
| echo "" >> deployment-report.md | |
| echo "## Healthcare Compliance Status" >> deployment-report.md | |
| if [ "${{ needs.healthcare-validation-gate.outputs.deployment-approved }}" == "true" ]; then | |
| echo "β **HEALTHCARE COMPLIANCE**: FULLY VALIDATED" >> deployment-report.md | |
| echo "β **CRISIS SYSTEMS**: OPERATIONAL" >> deployment-report.md | |
| echo "β **CLINICAL ACCURACY**: VALIDATED" >> deployment-report.md | |
| echo "β **HIPAA COMPLIANCE**: VALIDATED" >> deployment-report.md | |
| elif [ "${{ needs.healthcare-validation-gate.outputs.deployment-approved }}" == "emergency" ]; then | |
| echo "β οΈ **HEALTHCARE COMPLIANCE**: EMERGENCY DEPLOYMENT" >> deployment-report.md | |
| echo "β οΈ **VALIDATION SKIPPED**: Healthcare validation bypassed" >> deployment-report.md | |
| else | |
| echo "β **HEALTHCARE COMPLIANCE**: FAILED" >> deployment-report.md | |
| fi | |
| - name: π Upload Deployment Report | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: standard-deployment-report | |
| path: deployment-report.md | |
| retention-days: 365 | |
| - name: π Deployment Success Notification | |
| if: success() | |
| run: | | |
| echo "π STANDARD DEPLOYMENT SUCCESSFUL! π" | |
| echo "" | |
| echo "π FullMind MBCT Healthcare Application" | |
| echo "β Healthcare Validation: ${{ needs.healthcare-validation-gate.outputs.deployment-approved }}" | |
| echo "β Build Status: ${{ needs.production-build.result }}" | |
| echo "β Cloud Deployment: ${{ needs.cloud-deployment.result }}" | |
| echo "β Post-Deployment Validation: ${{ needs.post-deployment-validation.result }}" | |
| echo "" | |
| echo "π₯ Healthcare Systems: OPERATIONAL" | |
| echo "π Monitoring: ACTIVE (See monitoring workflow)" | |
| echo "π¨ Emergency Rollback: Available (See emergency-deploy workflow)" |