Skip to content

Update CI and deployment workflows to include --force flag for Fireba… #22

Update CI and deployment workflows to include --force flag for Fireba…

Update CI and deployment workflows to include --force flag for Fireba… #22

Workflow file for this run

name: CI/CD Pipeline
on:
pull_request:
branches: [ main, develop ]
push:
branches: [ main, develop ]
env:
NODE_VERSION: '22'
DEPLOY_PROD: false
jobs:
lint-and-build:
name: Lint and Build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Build application
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: build-files
path: .next/
retention-days: 1
test:
name: Playwright Tests
runs-on: ubuntu-latest
timeout-minutes: 60
needs: lint-and-build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npm run test
- name: Upload Playwright Report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: test-results.json
retention-days: 30
test-functions:
name: Firebase Functions Tests
runs-on: ubuntu-latest
timeout-minutes: 30
needs: lint-and-build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install main dependencies
run: npm ci
- name: Install Firebase Functions dependencies
run: npm run functions:install
- name: Build Firebase Functions
run: npm run functions:build
- name: Run Firebase Functions tests
run: npm run functions:test
- name: Verify Functions Tests Passed
if: success()
run: |
echo "✅ All Firebase Functions tests passed!"
echo "🚀 Functions are ready for deployment."
- name: Upload Functions Test Coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: functions-coverage
path: functions/coverage/
retention-days: 30
- name: Notify Test Failure
if: failure()
run: |
echo "❌ Firebase Functions tests failed!"
echo "🚫 Deployment will be skipped until tests pass."
echo "🔍 Check the test output above for details."
deploy-functions:
name: Deploy Firebase Functions
runs-on: ubuntu-latest
needs: [test-functions]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Firebase Functions dependencies
run: npm run functions:install
- name: Build Firebase Functions
run: npm run functions:build
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Deploy Firebase Functions
run: firebase deploy --only functions --token "${{ secrets.FIREBASE_TOKEN }}" --force
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
- name: Verify Functions Deployment
run: |
echo "✅ Firebase Functions deployed successfully!"
echo "🔍 Verifying deployment..."
firebase functions:list --token "${{ secrets.FIREBASE_TOKEN }}"
- name: Notify Deployment Success
if: success()
run: |
echo "🎉 Firebase Functions deployment completed successfully!"
echo "📊 Functions are now live and ready to handle requests."
echo "🔗 Check the Firebase Console for deployment details."
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
needs: [lint-and-build, test, deploy-functions]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Deploy to Firebase Hosting
run: firebase deploy --only hosting --token "${{ secrets.FIREBASE_TOKEN }}"
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}