-
Notifications
You must be signed in to change notification settings - Fork 8
112 lines (95 loc) · 3.35 KB
/
Copy pathstatic.yml
File metadata and controls
112 lines (95 loc) · 3.35 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
100
101
102
103
104
105
106
107
108
109
110
111
112
# When code is pushed to either main or dev branch:
# - main branch content gets deployed to the root (amche.in/)
# - dev branch content gets deployed to /dev/ (amche.in/dev/)
# Every push triggers deployment of BOTH branches, regardless of which branch received the push.
# this ensures both environments stay in sync with each deployment.
name: Deploy main and dev content to amche.in via 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:
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
# Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# Fetch and prepare main branch content
- name: Fetch main branch content into temporary directory
run: |
echo "Fetching main branch content..."
mkdir -p temp_main
git clone --branch main --depth 1 https://github.com/${{ github.repository }} temp_main
# Install dependencies and build main branch with Vite
- name: Build main branch
run: |
cd temp_main
echo "Installing dependencies..."
npm ci
echo "Running Vite build..."
npm run build
# Copy main branch build to deploy directory
- name: Copy main branch content to deploy directory
run: |
mkdir -p deploy
# Copy the contents of dist/ to deploy/
rsync -av temp_main/dist/ deploy/
# Create .nojekyll to disable Jekyll processing on GitHub Pages
touch deploy/.nojekyll
# Check if dev branch exists before attempting to fetch
- name: Check if dev branch exists
id: check_dev
run: |
if git ls-remote --heads https://github.com/${{ github.repository }} dev | grep 'dev'; then
echo "dev_exists=true" >> $GITHUB_ENV
else
echo "dev_exists=false" >> $GITHUB_ENV
fi
# Fetch and prepare dev branch content if it exists
- name: Fetch dev branch content into temporary directory
if: env.dev_exists == 'true'
run: |
echo "Fetching dev branch content..."
mkdir -p temp_dev
git clone --branch dev --depth 1 https://github.com/${{ github.repository }} temp_dev
# Install dependencies and build dev branch with Vite
- name: Build dev branch
if: env.dev_exists == 'true'
run: |
cd temp_dev
echo "Installing dependencies..."
npm ci
echo "Running Vite build..."
npm run build
# Copy dev branch content to /dev/ directory
- name: Copy dev branch content to /dev/ directory
if: env.dev_exists == 'true'
run: |
mkdir -p deploy/dev
rsync -av temp_dev/dist/ deploy/dev/
- name: Verify Content Structure
run: |
echo "Final deployment directory structure:"
tree deploy || echo "tree command not available"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: deploy
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4