Skip to content

Mobile support

Mobile support #20

Workflow file for this run

# CI/CD Pipeline for Snap2Slides
# Automated testing, building, and deployment workflow
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
release:
types: [published]
env:
NODE_VERSION: '18'
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# ===================
# Code Quality & Testing
# ===================
quality:
name: Code Quality & Testing
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup 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
- name: Run Prettier check
run: npm run format:check
- name: Run TypeScript type checking
run: npm run type-check
- name: Run tests
run: npm run test:ci
env:
CI: true
- name: Upload test coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
- name: Run security audit
run: npm run security:audit
# ===================
# Build & Validate
# ===================
build:
name: Build Application
runs-on: ubuntu-latest
needs: [quality]
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
env:
NODE_ENV: production
NEXT_TELEMETRY_DISABLED: 1
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-files
path: |
.next/
public/
retention-days: 7
# ===================
# Security Scanning
# ===================
security:
name: Security Scanning
runs-on: ubuntu-latest
needs: [quality]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
- name: Setup Node.js for security audit
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run npm audit
run: npm audit --audit-level high
# ===================
# Docker Build & Push
# ===================
docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: [quality, build]
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: runner
# ===================
# Deploy to Staging
# ===================
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: [docker]
if: github.ref == 'refs/heads/develop'
environment:
name: staging
url: https://staging.snap2slides.com
steps:
- name: Deploy to staging
run: |
echo "Deploying to staging environment..."
# Add your staging deployment commands here
# For example, deploy to Vercel staging environment
# npx vercel --token ${{ secrets.VERCEL_TOKEN }} --prod false
# ===================
# Deploy to Production
# ===================
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
needs: [docker]
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
environment:
name: production
url: https://snap2slides.com
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to Vercel
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-args: '--prod'
- name: Notify deployment success
if: success()
run: |
echo "✅ Production deployment successful!"
# Add notification logic here (Slack, Discord, etc.)
- name: Notify deployment failure
if: failure()
run: |
echo "❌ Production deployment failed!"
# Add failure notification logic here
# ===================
# Post-Deploy Health Check
# ===================
health-check:
name: Post-Deploy Health Check
runs-on: ubuntu-latest
needs: [deploy-production]
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
steps:
- name: Wait for deployment
run: sleep 30
- name: Health check
run: |
# Perform health checks on the deployed application
curl -f https://snap2slides.com/api/health || exit 1
echo "✅ Health check passed!"
- name: Run E2E tests
run: |
# Add end-to-end tests here
echo "Running E2E tests..."
# npx playwright test --config=playwright.config.prod.ts
# ===================
# Performance Testing
# ===================
performance:
name: Performance Testing
runs-on: ubuntu-latest
needs: [deploy-production]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Lighthouse CI
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
https://snap2slides.com
uploadArtifacts: true
temporaryPublicStorage: true
- name: Performance budget check
run: |
# Add performance budget validation
echo "Checking performance metrics..."
# ===================
# Cleanup
# ===================
cleanup:
name: Cleanup Old Artifacts
runs-on: ubuntu-latest
if: always()
needs: [quality, build, security, docker]
steps:
- name: Delete old artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: build-files
failOnError: false