Compare commits
2 Commits
d1d65de370
...
f07dcc4c87
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f07dcc4c87 | ||
|
|
3d593183fb |
176
.github/workflows/deploy-preprod.yml
vendored
176
.github/workflows/deploy-preprod.yml
vendored
@ -22,10 +22,6 @@ jobs:
|
|||||||
name: Backend - Build & Test
|
name: Backend - Build & Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ./apps/backend
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Checkout code
|
# Checkout code
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
@ -37,7 +33,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: apps/backend/package-lock.json
|
cache-dependency-path: package-lock.json
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
@ -62,59 +58,9 @@ jobs:
|
|||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: backend-dist
|
name: backend-dist
|
||||||
path: apps/backend/dist
|
path: dist
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# JOB 2: Frontend - Build and Test
|
|
||||||
# ============================================================================
|
|
||||||
frontend-build-test:
|
|
||||||
name: Frontend - Build & Test
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ./apps/frontend
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# Checkout code
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
# Setup Node.js
|
|
||||||
- name: Set up Node.js ${{ env.NODE_VERSION }}
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache: 'npm'
|
|
||||||
cache-dependency-path: apps/frontend/package-lock.json
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
# Run linter (warnings allowed, only errors fail the build)
|
|
||||||
- name: Run ESLint
|
|
||||||
run: npm run lint -- --quiet || true
|
|
||||||
|
|
||||||
# Type check (temporarily disabled - too many errors to fix)
|
|
||||||
# - name: TypeScript Type Check
|
|
||||||
# run: npm run type-check
|
|
||||||
|
|
||||||
# Build frontend
|
|
||||||
- name: Build Frontend
|
|
||||||
run: npm run build
|
|
||||||
env:
|
|
||||||
NEXT_PUBLIC_API_URL: https://api-preprod.xpeditis.com
|
|
||||||
NEXT_PUBLIC_WS_URL: wss://api-preprod.xpeditis.com
|
|
||||||
|
|
||||||
# Upload build artifacts
|
|
||||||
- name: Upload Frontend Build Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: frontend-build
|
|
||||||
path: apps/frontend/.next
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# JOB 3: Backend - Docker Build & Push
|
# JOB 3: Backend - Docker Build & Push
|
||||||
@ -159,7 +105,7 @@ jobs:
|
|||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./apps/backend/Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
@ -173,64 +119,6 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
run: docker system prune -af
|
run: docker system prune -af
|
||||||
|
|
||||||
# ============================================================================
|
|
||||||
# JOB 4: Frontend - Docker Build & Push
|
|
||||||
# ============================================================================
|
|
||||||
frontend-docker:
|
|
||||||
name: Frontend - Docker Build & Push
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [frontend-build-test]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
# Setup QEMU for multi-platform builds
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
# Setup Docker Buildx
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
# Login to Scaleway Registry
|
|
||||||
- name: Login to Scaleway Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: rg.fr-par.scw.cloud/xpeditis
|
|
||||||
username: nologin
|
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
|
|
||||||
# Extract metadata for Docker
|
|
||||||
- name: Extract Docker Metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.FRONTEND_IMAGE }}
|
|
||||||
tags: |
|
|
||||||
type=raw,value=preprod
|
|
||||||
type=sha,prefix=preprod-
|
|
||||||
|
|
||||||
# Build and push Docker image
|
|
||||||
- name: Build and Push Frontend Image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./apps/frontend/Dockerfile
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=registry,ref=${{ env.FRONTEND_IMAGE }}:buildcache
|
|
||||||
cache-to: type=registry,ref=${{ env.FRONTEND_IMAGE }}:buildcache,mode=max
|
|
||||||
build-args: |
|
|
||||||
NODE_ENV=production
|
|
||||||
NEXT_PUBLIC_API_URL=https://api-preprod.xpeditis.com
|
|
||||||
NEXT_PUBLIC_WS_URL=wss://api-preprod.xpeditis.com
|
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
- name: Docker Cleanup
|
|
||||||
if: always()
|
|
||||||
run: docker system prune -af
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# JOB 5: Deploy to PreProd Server (Portainer Webhook)
|
# JOB 5: Deploy to PreProd Server (Portainer Webhook)
|
||||||
@ -238,7 +126,7 @@ jobs:
|
|||||||
deploy-preprod:
|
deploy-preprod:
|
||||||
name: Deploy to PreProd Server
|
name: Deploy to PreProd Server
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [backend-docker, frontend-docker]
|
needs: [backend-docker]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
@ -255,16 +143,6 @@ jobs:
|
|||||||
- name: Wait for Backend Deployment
|
- name: Wait for Backend Deployment
|
||||||
run: sleep 30
|
run: sleep 30
|
||||||
|
|
||||||
- name: Trigger Portainer Webhook - Frontend
|
|
||||||
run: |
|
|
||||||
curl -X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"service": "frontend", "image": "${{ env.FRONTEND_IMAGE }}:preprod", "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' \
|
|
||||||
${{ secrets.PORTAINER_WEBHOOK_FRONTEND }}
|
|
||||||
|
|
||||||
- name: Wait for Frontend Deployment
|
|
||||||
run: sleep 30
|
|
||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
- name: Health Check - Backend API
|
- name: Health Check - Backend API
|
||||||
run: |
|
run: |
|
||||||
@ -289,29 +167,6 @@ jobs:
|
|||||||
echo "❌ Backend API health check failed after $MAX_RETRIES attempts"
|
echo "❌ Backend API health check failed after $MAX_RETRIES attempts"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Health Check - Frontend
|
|
||||||
run: |
|
|
||||||
MAX_RETRIES=10
|
|
||||||
RETRY_COUNT=0
|
|
||||||
|
|
||||||
echo "Waiting for frontend to be healthy..."
|
|
||||||
|
|
||||||
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
|
||||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://app-preprod.xpeditis.com || echo "000")
|
|
||||||
|
|
||||||
if [ "$HTTP_CODE" = "200" ]; then
|
|
||||||
echo "✅ Frontend is healthy (HTTP $HTTP_CODE)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
|
||||||
echo "⏳ Attempt $RETRY_COUNT/$MAX_RETRIES - Frontend returned HTTP $HTTP_CODE, retrying in 10s..."
|
|
||||||
sleep 10
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "❌ Frontend health check failed after $MAX_RETRIES attempts"
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
# Send deployment notification
|
# Send deployment notification
|
||||||
- name: Send Deployment Notification
|
- name: Send Deployment Notification
|
||||||
if: always()
|
if: always()
|
||||||
@ -340,8 +195,7 @@ jobs:
|
|||||||
\"description\": \"**Branch:** preprod\n**Commit:** [\`$COMMIT_SHORT\`](https://github.com/${{ github.repository }}/commit/$COMMIT_SHA)\n**Author:** $AUTHOR\n**Message:** $COMMIT_MSG\",
|
\"description\": \"**Branch:** preprod\n**Commit:** [\`$COMMIT_SHORT\`](https://github.com/${{ github.repository }}/commit/$COMMIT_SHA)\n**Author:** $AUTHOR\n**Message:** $COMMIT_MSG\",
|
||||||
\"color\": $COLOR,
|
\"color\": $COLOR,
|
||||||
\"fields\": [
|
\"fields\": [
|
||||||
{\"name\": \"Backend\", \"value\": \"https://api-preprod.xpeditis.com\", \"inline\": true},
|
{\"name\": \"Backend API\", \"value\": \"https://api-preprod.xpeditis.com\", \"inline\": true}
|
||||||
{\"name\": \"Frontend\", \"value\": \"https://app-preprod.xpeditis.com\", \"inline\": true}
|
|
||||||
],
|
],
|
||||||
\"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"
|
\"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"
|
||||||
}]
|
}]
|
||||||
@ -398,25 +252,6 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "✅ Rate search endpoint OK (HTTP $HTTP_CODE)"
|
echo "✅ Rate search endpoint OK (HTTP $HTTP_CODE)"
|
||||||
|
|
||||||
# Test Frontend
|
|
||||||
- name: Test Frontend - Homepage
|
|
||||||
run: |
|
|
||||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://app-preprod.xpeditis.com)
|
|
||||||
if [ "$HTTP_CODE" != "200" ]; then
|
|
||||||
echo "❌ Frontend homepage failed (HTTP $HTTP_CODE)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "✅ Frontend homepage OK"
|
|
||||||
|
|
||||||
- name: Test Frontend - Login Page
|
|
||||||
run: |
|
|
||||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://app-preprod.xpeditis.com/login)
|
|
||||||
if [ "$HTTP_CODE" != "200" ]; then
|
|
||||||
echo "❌ Frontend login page failed (HTTP $HTTP_CODE)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "✅ Frontend login page OK"
|
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
- name: Tests Summary
|
- name: Tests Summary
|
||||||
run: |
|
run: |
|
||||||
@ -424,6 +259,5 @@ jobs:
|
|||||||
echo "✅ All smoke tests passed successfully!"
|
echo "✅ All smoke tests passed successfully!"
|
||||||
echo "================================================"
|
echo "================================================"
|
||||||
echo "Backend API: https://api-preprod.xpeditis.com"
|
echo "Backend API: https://api-preprod.xpeditis.com"
|
||||||
echo "Frontend App: https://app-preprod.xpeditis.com"
|
|
||||||
echo "Swagger Docs: https://api-preprod.xpeditis.com/api/docs"
|
echo "Swagger Docs: https://api-preprod.xpeditis.com/api/docs"
|
||||||
echo "================================================"
|
echo "================================================"
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
"target": "ES2021",
|
"target": "ES2021",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"baseUrl": ".",
|
"baseUrl": "./",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user