-
Notifications
You must be signed in to change notification settings - Fork 4
152 lines (126 loc) · 4.97 KB
/
deploy-to-pages.yml
File metadata and controls
152 lines (126 loc) · 4.97 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Deploy to GitHub Pages
on:
# Runs on pushes to any branch to validate build (only when code changes)
push:
paths-ignore:
- '**.md'
- 'LICENSE'
- 'SECURITY.md'
# Runs on pull requests to validate build (only when code changes)
pull_request:
paths-ignore:
- '**.md'
- 'LICENSE'
- 'SECURITY.md'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment per branch
concurrency:
group: "pages-${{ github.head_ref || github.ref }}"
cancel-in-progress: true
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: "20"
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build for GitHub Pages
run: npm run build:pages
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
# Deployment job
deploy:
# Only deploy on main branch
# if: github.ref == 'refs/heads/main'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- name: Smoke Test - Check CSV Upload Button
run: |
echo "Running smoke test on deployed site..."
SITE_URL="${{ steps.deployment.outputs.page_url }}"
echo "Testing URL: $SITE_URL"
# Wait a bit for deployment to be fully available
sleep 30
# First, check if the site is accessible and returns the expected HTML structure
echo "Checking if site is accessible..."
RESPONSE=$(curl -fsSL "$SITE_URL" || exit 1)
# Check if the HTML contains the root div where React will mount
if echo "$RESPONSE" | grep -q '<div id="root"></div>'; then
echo "✅ Basic HTML structure found"
else
echo "❌ Basic HTML structure missing"
exit 1
fi
# Check if JavaScript bundle is referenced
if echo "$RESPONSE" | grep -q 'type="module".*\.js'; then
echo "✅ JavaScript bundle reference found"
else
echo "❌ JavaScript bundle reference missing"
exit 1
fi
# Check if CSS is referenced
if echo "$RESPONSE" | grep -q 'rel="stylesheet".*\.css'; then
echo "✅ CSS stylesheet reference found"
else
echo "❌ CSS stylesheet reference missing"
exit 1
fi
# Test if the JavaScript bundle is accessible and contains the CSV upload button text
JS_URL=$(echo "$RESPONSE" | grep -o 'src="[^"]*\.js"' | sed 's/src="//;s/"//' | head -1)
if [[ "$JS_URL" == ./* ]]; then
JS_URL="${SITE_URL%/}/${JS_URL#./}"
fi
echo "Testing JavaScript bundle at: $JS_URL"
JS_CONTENT=$(curl -fsSL "$JS_URL" || exit 1)
if echo "$JS_CONTENT" | head -c 1000 | grep -q "function\|const\|var\|class"; then
echo "✅ JavaScript bundle is accessible and contains expected code"
else
echo "❌ JavaScript bundle is not accessible or doesn't contain expected code"
exit 1
fi
# Check if the JavaScript bundle contains the CSV upload button text
if echo "$JS_CONTENT" | grep -q "Select CSV File"; then
echo "✅ CSV upload button text found in JavaScript bundle"
else
echo "❌ CSV upload button text not found in JavaScript bundle"
echo "This indicates the core CSV upload functionality is missing from the build"
exit 1
fi
# Test if the CSS bundle is accessible
CSS_URL=$(echo "$RESPONSE" | grep -o 'href="[^"]*\.css"' | sed 's/href="//;s/"//' | head -1)
if [[ "$CSS_URL" == ./* ]]; then
CSS_URL="${SITE_URL%/}/${CSS_URL#./}"
fi
echo "Testing CSS bundle at: $CSS_URL"
CSS_CONTENT=$(curl -fsSL "$CSS_URL" || exit 1)
if echo "$CSS_CONTENT" | grep -q "body\|html\|\."; then
echo "✅ CSS bundle is accessible and contains expected styles"
else
echo "❌ CSS bundle is not accessible or doesn't contain expected styles"
exit 1
fi
echo "✅ Smoke test passed: All essential resources are accessible and CSV upload functionality is present"