Skip to content

Commit da1acd9

Browse files
YuvalYuval
authored andcommitted
fix(ci): let publish self-restore, bundle package.json for SPA host
Backend: the Ubuntu runner preinstalls newer .NET SDKs that pick up precedence over our requested 8.0.x, so `dotnet restore` (no RID) produced an assets file without a linux-x64 target, breaking `publish -r linux-x64 --no-restore`. Drop the separate restore step and let publish restore itself; also pin the csproj explicitly to avoid the solution-level --output warning. Frontend: bundle a minimal package.json with `pm2 serve . --spa` as the start script so App Service auto-detects it and runs it — no reliance on a Portal-configured Startup Command. Loosen the health check window to tolerate the first cold Oryx build.
1 parent aa66672 commit da1acd9

1 file changed

Lines changed: 30 additions & 13 deletions

File tree

.github/workflows/cd.yml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ jobs:
5151
with:
5252
dotnet-version: "8.0.x"
5353

54-
- name: Restore
55-
run: dotnet restore
56-
5754
# Publish targeting linux-x64 so the output matches the App Service
5855
# runtime and does NOT include runtimes/win/* (backslash paths in those
5956
# files have historically corrupted wwwroot on Linux App Service).
57+
#
58+
# We let `publish` do its own restore here. The Ubuntu runner ships
59+
# newer .NET SDKs alongside 8.0, and a prior `dotnet restore` without
60+
# an explicit RID produced an assets file that didn't satisfy
61+
# `publish -r linux-x64 --no-restore`.
6062
- name: Publish (linux-x64, framework-dependent)
61-
run: dotnet publish -c Release -r linux-x64 --self-contained false -o ./publish-linux --no-restore
63+
run: dotnet publish WebApplication1.csproj -c Release -r linux-x64 --self-contained false -o ./publish-linux
6264

6365
# Zip on Linux so path separators are forward slashes. Paired with
6466
# WEBSITE_RUN_FROM_PACKAGE=1 on the App Service, the deploy mounts the
@@ -114,15 +116,28 @@ jobs:
114116
env:
115117
VITE_API_BASE_URL: https://app-groundshare-api.azurewebsites.net/api
116118

117-
# Zip only the built dist/ so the App Service wwwroot contains the SPA
118-
# files at its root. The App Service Startup Command serves them via:
119-
# pm2 serve /home/site/wwwroot --no-daemon --spa
120-
# `--spa` makes unmatched routes fall back to index.html so client-side
121-
# routing (React Router) works on deep links and page refreshes.
119+
# Zip the built dist/ along with a minimal package.json so Azure App
120+
# Service (Linux Node) auto-starts it via `npm start`. The start script
121+
# uses pm2's built-in static server with `--spa` so unmatched routes
122+
# fall back to index.html (required for React Router deep links).
123+
#
124+
# Doing it this way removes the need to set a Startup Command in the
125+
# Portal — the zip is self-describing.
122126
- name: Package dist
123127
working-directory: 03-Client
124128
run: |
125-
cd dist
129+
cp -r dist deploy-frontend
130+
cat > deploy-frontend/package.json <<'JSON'
131+
{
132+
"name": "groundshare-web",
133+
"version": "1.0.0",
134+
"private": true,
135+
"scripts": {
136+
"start": "pm2 serve . --no-daemon --spa"
137+
}
138+
}
139+
JSON
140+
cd deploy-frontend
126141
zip -r ../deploy-frontend.zip .
127142
128143
- name: Deploy to Azure App Service (frontend)
@@ -132,10 +147,12 @@ jobs:
132147
publish-profile: ${{ secrets.AZURE_WEBAPP_FRONTEND_PUBLISH_PROFILE }}
133148
package: 03-Client/deploy-frontend.zip
134149

150+
# First-time Oryx build + pm2 warmup on a cold Free-tier App Service
151+
# can take 2-3 minutes. Poll for up to ~4 minutes before failing.
135152
- name: Health check
136153
run: |
137-
sleep 30
138-
for i in 1 2 3 4 5; do
154+
sleep 60
155+
for i in $(seq 1 12); do
139156
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://app-groundshare-web.azurewebsites.net/ || true)
140157
if [ "$STATUS" = "200" ]; then
141158
echo "Health check passed"
@@ -144,5 +161,5 @@ jobs:
144161
echo "Attempt $i: status $STATUS, retrying in 15s..."
145162
sleep 15
146163
done
147-
echo "Health check failed after 5 attempts"
164+
echo "Health check failed"
148165
exit 1

0 commit comments

Comments
 (0)