Back to .md Directory

GitHub Actions CI/CD Pipeline

Defines GitHub Actions workflows for testing, building, and deploying a Vite app to Vercel with analytics.

May 2, 2026
0 downloads
0 views
ai rag workflow
View source

What this file does

Defines GitHub Actions workflows for testing, building, and deploying a Vite app to Vercel with analytics.

When to use it

  • You need automated CI/CD for a Vite app deployed to Vercel
  • You want separate validation for PRs and full pipeline for main/develop branches
  • You require E2E tests across multiple browsers and mobile viewports
  • You want Vercel Analytics enabled automatically on deploy

Assumes this stack

GitHub ActionsViteVercelVitestPlaywrightpnpm

GitHub Actions CI/CD Pipeline

This directory contains GitHub Actions workflows for automated testing, building, and deployment of the Interview Timer application.

Workflows

1. CI/CD Pipeline (ci-cd.yml)

Triggers:

  • Push to main or develop branches
  • Pull requests to main or develop branches

Jobs:

Unit Tests

  • Runs Vitest unit tests
  • Generates coverage reports
  • Uploads coverage to Codecov

E2E Tests

  • Runs Playwright end-to-end tests
  • Tests across multiple browsers (Chrome, Firefox, Safari)
  • Tests mobile viewports
  • Uploads test reports and artifacts

Lint

  • Runs Prettier code formatting checks
  • Ensures code style consistency

Build

  • Builds the application using Vite
  • Uploads build artifacts
  • Only runs after all tests pass

Deploy to Vercel

  • Deploys to Vercel production environment
  • Only runs on pushes to main branch
  • Requires Vercel secrets to be configured
  • Automatically enables Vercel Analytics for web analytics tracking

Security Scan

  • Runs pnpm audit for dependency vulnerabilities
  • Checks for moderate and high severity issues

2. Pull Request Validation (pr-validation.yml)

Triggers:

  • Pull requests to main or develop branches

Features:

  • Quick validation for PRs (linting, unit tests, build)
  • Comments on PR with validation results
  • Faster feedback loop for contributors

Analytics Integration

The application uses Vercel Analytics for web analytics:

  • Automatic Setup: Analytics are automatically enabled when deployed to Vercel
  • Privacy-Focused: No cookies required, GDPR compliant
  • Development Mode: Analytics are automatically disabled in development
  • No Configuration: The @vercel/analytics package handles everything automatically

Analytics Features

  • Page views and user interactions
  • Performance metrics
  • Error tracking
  • Real-time analytics dashboard in Vercel

Required Secrets

To enable Vercel deployment, configure these secrets in your GitHub repository:

Vercel Secrets

  1. Go to your GitHub repository settings
  2. Navigate to "Secrets and variables" โ†’ "Actions"
  3. Add the following repository secrets:
VERCEL_TOKEN=your_vercel_token
VERCEL_ORG_ID=your_vercel_org_id
VERCEL_PROJECT_ID=your_vercel_project_id

How to Get Vercel Credentials

  1. VERCEL_TOKEN:

  2. VERCEL_ORG_ID:

    • Go to your Vercel team settings
    • Copy the Organization ID from the URL or settings
  3. VERCEL_PROJECT_ID:

    • Go to your project settings in Vercel
    • Copy the Project ID from the settings page

Environment Variables

The workflows use the following environment variables:

  • NODE_VERSION: '22' (Node.js version)
  • PNPM_VERSION: '8' (pnpm version)

pnpm Configuration

The project includes a .pnpmrc file to configure pnpm for CI environments:

  • Build Scripts: Enabled to allow esbuild and other build tools to run
  • Pre/Post Scripts: Enabled for proper dependency installation
  • Security: Only allows specific script types (build, postinstall, preinstall, install)

This configuration ensures that:

  • Vite can use esbuild for building
  • Playwright can install browser binaries
  • All necessary build scripts run in CI environments

Caching

The workflows implement intelligent caching for:

  • pnpm store directory
  • Node.js dependencies
  • Build artifacts

This significantly reduces build times and improves CI/CD performance.

Test Coverage

  • Unit tests generate coverage reports using Vitest
  • Coverage reports are uploaded to Codecov
  • E2E tests provide comprehensive browser testing

Deployment Strategy

  • Pull Requests: Only validation (no deployment)
  • Develop Branch: Full CI/CD pipeline (no production deployment)
  • Main Branch: Full CI/CD pipeline + production deployment to Vercel

Monitoring and Debugging

Failed Tests

  • Playwright reports are uploaded as artifacts
  • Test results include screenshots and videos for failed tests
  • Coverage reports help identify untested code

Build Failures

  • Build artifacts are uploaded for debugging
  • Detailed logs are available in GitHub Actions

Deployment Issues

  • Vercel deployment logs are available in the workflow
  • Check Vercel dashboard for deployment status

Local Development

To run the same checks locally:

# Install dependencies
pnpm install

# Run linting
pnpm run lint

# Run unit tests
pnpm run test:unit

# Run unit tests with coverage
pnpm run test:unit:coverage

# Run E2E tests
pnpm run test:e2e

# Build application
pnpm run build

Troubleshooting

Common Issues

  1. Vercel Deployment Fails

    • Verify all required secrets are set
    • Check Vercel project configuration
    • Ensure build command works locally
  2. Tests Fail in CI but Pass Locally

    • Check for environment-specific issues
    • Verify all dependencies are properly installed
    • Review test setup and configuration
  3. Build Fails

    • Ensure all dependencies are in package.json
    • Check for TypeScript or linting errors
    • Verify build configuration

Getting Help

  • Check GitHub Actions logs for detailed error messages
  • Review the workflow files for configuration issues
  • Ensure all required secrets and environment variables are set

What's inside

2 workflow definitions, 6 job types, 3 required secrets, 3 environment variables, 1 pnpmrc config, 1 analytics section

Change this for your project

  • Replace VERCEL_TOKEN, VERCEL_ORG_ID, and VERCEL_PROJECT_ID with your own Vercel credentials
  • Replace NODE_VERSION: '22' and PNPM_VERSION: '8' with your required versions
  • Replace betsalel-williamson/interview-timer repository references with your own repo name

Where it goes

Keep it in your repository where the agent or team that needs it will read it.

Worth borrowing

  • Separate PR validation workflow for faster feedback vs full pipeline on push
  • Caching pnpm store and Node dependencies to reduce build times
  • Uploading Playwright test artifacts (screenshots, videos) for debugging failures

Related Documents