Deploy Svelte on Netlify with GitHub Actions

🔥 Svelte 🌐 Netlify 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 Netlify

on:
  push:
    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 Netlify
        uses: nwtgck/actions-netlify@v2
        with:
          publish-dir: './build'
          production-branch: main
          github-token: ${{ secrets.GITHUB_TOKEN }}
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

Prerequisites

  • Netlify account
  • SvelteKit project with adapter-static
  • GitHub repository

Deployment Steps

  • 1. Create Netlify account
  • 2. Create new site
  • 3. Get Site ID and Auth Token
  • 4. Add secrets to GitHub
  • 5. Create workflow file
  • 6. Push to deploy

Additional Notes

  • ⚡ Lightning-fast builds
  • 🔀 Deploy previews
  • 💰 Free: 100GB bandwidth
  • ⚠️ Use adapter-netlify for SSR