Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/deploy-front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,19 @@ jobs:

# Warm-up: force ISR regeneration so first real user gets data
- name: Warm-up (force ISR regeneration)
env:
SITE_URL: https://info-embalse-front-prod-ecguababcfdsepga.westeurope-01.azurewebsites.net
REVALIDATION_SECRET: ${{ secrets.REVALIDATION_SECRET }}
run: |
echo "Waiting for App Service to start..."
sleep 30
curl -s -o /dev/null -w "%{http_code}" https://info-embalse-front-prod-ecguababcfdsepga.westeurope-01.azurewebsites.net/
echo " - Warm-up done, ISR regeneration triggered"
for i in $(seq 1 10); do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$SITE_URL/" || true)
echo " Attempt $i: HTTP $STATUS"
if [ "$STATUS" = "200" ]; then break; fi
sleep 10
done
echo "Triggering on-demand revalidation..."
curl -s "$SITE_URL/api/revalidate?secret=$REVALIDATION_SECRET"
sleep 2
curl -s -o /dev/null "$SITE_URL/"
echo "Warm-up complete"
1 change: 1 addition & 0 deletions front/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ENV PORT=3000
# - public assets in /public
COPY --from=builder /app/front/.next/standalone ./
COPY --from=builder /app/front/.next/static ./front/.next/static
COPY --from=builder /app/front/.next/cache ./front/.next/cache
COPY --from=builder /app/front/public ./front/public

EXPOSE 3000
Expand Down
12 changes: 12 additions & 0 deletions front/src/app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { revalidatePath } from "next/cache";
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest) {
const secret = request.nextUrl.searchParams.get("secret");
if (secret !== process.env.REVALIDATION_SECRET) {
return NextResponse.json({ message: "Invalid secret" }, { status: 401 });
}

revalidatePath("/");
return NextResponse.json({ revalidated: true });
}