Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Deployment Setup Guide

This repository is configured for automatic deployment to Netlify using GitHub Actions.

## Required GitHub Secrets

To enable automatic deployment, you need to add these secrets in your GitHub repository:

### 1. NETLIFY_AUTH_TOKEN
1. Go to [Netlify](https://app.netlify.com)
2. Navigate to **User Settings** → **Applications** → **Personal access tokens**
3. Click **"New access token"**
4. Give it a name (e.g., "JSON Viewer GitHub Actions")
5. Copy the generated token
6. In GitHub: **Settings** → **Secrets and variables** → **Actions** → **New repository secret**
7. Name: `NETLIFY_AUTH_TOKEN`
8. Value: Paste the token

### 2. NETLIFY_SITE_ID
1. In Netlify, go to your site dashboard
2. Navigate to **Site settings** → **General** → **Site details**
3. Copy the **Site ID** (format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)
4. In GitHub: **Settings** → **Secrets and variables** → **Actions** → **New repository secret**
5. Name: `NETLIFY_SITE_ID`
6. Value: Paste the Site ID

## How It Works

- **Automatic Deployment**: Every push to `main` branch triggers a build and deployment
- **Pull Request Previews**: PRs create preview deployments for testing
- **Build Caching**: npm dependencies are cached for faster builds
- **Security Headers**: Netlify.toml includes security and performance headers

## Manual Deployment

If you need to deploy manually:

```bash
npm run build
netlify deploy --prod --dir=dist
```

## Troubleshooting

### Build Fails
- Check the GitHub Actions log for detailed error messages
- Ensure all dependencies are listed in package.json
- Verify Node.js version compatibility (using Node 20)

### Deployment Fails
- Verify both secrets are correctly set in GitHub
- Check that NETLIFY_SITE_ID matches your Netlify site
- Ensure NETLIFY_AUTH_TOKEN has proper permissions

### Custom Domain
- Configure custom domain in Netlify dashboard
- Update DNS records to point to Netlify
- SSL certificates are automatically generated

## Support

For issues with deployment, check:
1. GitHub Actions workflow logs
2. Netlify deployment logs
3. Ensure secrets are properly configured
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Deploy to Netlify

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

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
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: Run Tests (if any)
run: npm run test --if-present

- name: Build Project
run: npm run build

- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v3.0
with:
publish-dir: './dist'
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,11 @@ ga-key.json
Dockerfile*
docker-compose*

# Kubernetes
# Kubernetes (but not GitHub workflows or config files)
*.yaml
*.yml
!.github/**/*.yml
!.github/**/*.yaml
!package.json
!tsconfig.json
!vite.config.ts
Expand Down
34 changes: 34 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[build]
command = "npm run build"
publish = "dist"

[build.environment]
NODE_VERSION = "20"

# Redirect all routes to index.html for SPA
[[redirects]]
from = "/*"
to = "/index.html"
status = 200

# Development server configuration
[dev]
command = "npm run dev"
port = 5173
publish = "dist"

# Headers for security and performance
[[headers]]
for = "/*"
[headers.values]
X-Frame-Options = "DENY"
X-XSS-Protection = "1; mode=block"
X-Content-Type-Options = "nosniff"
Referrer-Policy = "strict-origin-when-cross-origin"
Permissions-Policy = "camera=(), microphone=(), geolocation=()"

# Cache static assets
[[headers]]
for = "/assets/*"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
Loading