-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (76 loc) · 2.15 KB
/
Copy pathdeploy.yml
File metadata and controls
91 lines (76 loc) · 2.15 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
name: Deploy to GitHub Pages
on:
push:
branches: [ main, dev ]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
path: main
- name: Checkout dev branch
uses: actions/checkout@v4
with:
ref: dev
path: dev
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: |
main/package-lock.json
dev/package-lock.json
- name: Build main branch
run: |
cd main
npm ci
npm run build
cd ..
- name: Build dev branch
run: |
cd dev
npm ci
npm run build
# Rename index.html to dev.html for dev branch
mv dist/index.html dist/dev.html
cd ..
- name: Combine builds
run: |
# Create final dist directory
mkdir -p dist
# Copy main build (production)
cp -r main/dist/* dist/
# Copy dev build file
cp dev/dist/dev.html dist/
# Copy any assets from dev that might be different
# but prioritize main assets for production
for file in dev/dist/*; do
filename=$(basename "$file")
if [ "$filename" != "dev.html" ] && [ "$filename" != "index.html" ]; then
# Only copy if it doesn't exist in main
if [ ! -f "dist/$filename" ]; then
cp "$file" dist/
fi
fi
done
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4