Deploy Astro on Vercel with GitHub Actions

🚀 Astro ▲ Vercel Platform ⚙️ GitHub Actions

Configuration Files

Production-ready configuration files with detailed comments and best practices. Each file works together as a complete deployment solution.
name: Deploy to Vercel

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

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - name: Install dependencies
        run: npm ci

      - name: Build
        run: npm run build

      - 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'

Prerequisites

  • Vercel account (free tier available)
  • Astro project initialized
  • GitHub repository
  • Node.js 18+ installed

Deployment Steps

  • 1. Create Vercel account and project
  • 2. Install Vercel CLI: npm i -g vercel
  • 3. Link project: vercel link
  • 4. Get tokens: vercel --token (for CI)
  • 5. Add secrets to GitHub: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID
  • 6. Create .github/workflows/deploy.yml
  • 7. Push to trigger deployment
  • 8. Verify at your-project.vercel.app

Additional Notes

  • ⚡ Zero-config deployments
  • 🌍 Global edge network
  • 📊 Built-in analytics
  • 🔒 Automatic HTTPS
  • 💰 Free: 100GB bandwidth/month
  • ⚠️ Use @astrojs/vercel adapter for SSR