-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-netlify.yml
More file actions
99 lines (87 loc) · 2.8 KB
/
deploy-netlify.yml
File metadata and controls
99 lines (87 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Deploy to Netlify
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
deploy-preview:
name: Deploy Preview
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
environment:
name: preview
url: ${{ steps.deploy.outputs.deploy-url }}
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: Build
run: npm run build
env:
NODE_ENV: production
- name: Deploy to Netlify (Preview)
id: deploy
uses: nwtgck/actions-netlify@v3
with:
publish-dir: './dist'
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions - PR #${{ github.event.pull_request.number }}"
enable-pull-request-comment: true
enable-commit-comment: false
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
deploy-production:
name: Deploy Production
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment:
name: production
url: ${{ steps.deploy.outputs.deploy-url }}
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: Build
run: npm run build
env:
NODE_ENV: production
- name: Deploy to Netlify (Production)
id: deploy
uses: nwtgck/actions-netlify@v3
with:
publish-dir: './dist'
production-deploy: true
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions - ${{ github.sha }}"
enable-commit-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# Setup Instructions:
# 1. Create a site on Netlify (manually or via CLI)
# 2. Get your Site ID from Site Settings > General > Site details
# 3. Get your Auth Token from User Settings > Applications > Personal access tokens
# 4. Add secrets to GitHub:
# - NETLIFY_AUTH_TOKEN: Your personal access token
# - NETLIFY_SITE_ID: Your site ID (found in site settings)
# 5. Adjust 'publish-dir' to match your build output directory:
# - Next.js: out
# - Vite: dist
# - Astro: dist
# - Create React App: build