ci(workflows): update Gitea CI/CD pipelines for Next.js 15 deployment

Update both production and alpha deployment workflows:

Changes:
- Updated Node.js version from 22 to 20 (match project dependencies)
- Changed build command from Angular 'npm run build --prod' to Next.js 'npm run build'
- Added environment variables for API URLs (PROD_API_URL, ALPHA_API_URL)
- Added NODE_ENV=production build argument for Docker
- Improved Docker image tagging strategy (separate prod/alpha namespaces)
- Enhanced kubeconfig validation with better error handling
- Added deployment status messaging for better workflow visibility
- Removed hardcoded config checking that exposed secrets
- Added rollout status timeout (5m) for safer deployments
- Improved step descriptions for clarity

Benefits:
- Workflow now properly builds Next.js standalone output
- Better separation of prod and alpha deployments
- Improved error reporting and troubleshooting
- Safer kubeconfig handling (no secrets exposure)
- More reliable deployment with timeout checks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Alexis Bruneteau 2025-10-17 00:59:18 +02:00
parent 2d07eeba10
commit 53905cb9e2
2 changed files with 59 additions and 34 deletions

View File

@ -1,4 +1,4 @@
name: Build and Deploy to k3s
name: Build and Deploy to k3s (Alpha)
on:
push:
tags:
@ -16,27 +16,31 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Build Angular app
run: npm run build --prod
- name: Build Next.js app
run: npm run build
env:
NEXT_PUBLIC_API_URL: ${{ secrets.ALPHA_API_URL }}
- name: Build Docker image
run: |
docker build -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend:${{ github.sha }} .
docker tag ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend:${{ github.sha }} ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend:latest
docker build \
-t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-alpha:${{ github.sha }} \
-t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-alpha:latest \
--build-arg NODE_ENV=production \
.
- name: Login to Container Registry
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_URL }} -u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Push Docker image
- name: Push Docker images
run: |
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend:${{ github.sha }}
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend:latest
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-alpha:${{ github.sha }}
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-alpha:latest
- name: Setup kubectl
uses: azure/setup-kubectl@v3
@ -49,22 +53,29 @@ jobs:
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
- name: Check Config
- name: Validate kubeconfig and cluster connectivity
run: |
cat ~/.kube/config
- name: Validate kubeconfig
run: |
if ! kubectl version --client && kubectl cluster-info --kubeconfig ~/.kube/config; then
if ! kubectl version --client; then
echo "❌ Failed to get kubectl version"
exit 1
fi
if ! kubectl cluster-info --kubeconfig ~/.kube/config > /dev/null 2>&1; then
echo "❌ Failed to connect to cluster"
exit 1
fi
echo "✅ Successfully connected to Kubernetes cluster"
- name: Deploy to k3s
- name: Deploy to Alpha (k3s)
run: |
echo "Applying Kubernetes manifests..."
kubectl apply -k deploy/k3s/alpha --kubeconfig ~/.kube/config
echo "Updating deployment image..."
kubectl set image deployment/hosting-frontend \
hosting-frontend=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend:${{ github.sha }} \
hosting-frontend=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-alpha:${{ github.sha }} \
-n hosting-alpha --kubeconfig ~/.kube/config
kubectl rollout status deployment/hosting-frontend -n hosting-alpha --kubeconfig ~/.kube/config
echo "Waiting for rollout to complete..."
kubectl rollout status deployment/hosting-frontend -n hosting-alpha --kubeconfig ~/.kube/config --timeout=5m
echo "✅ Alpha deployment complete!"

View File

@ -1,4 +1,4 @@
name: Build and Deploy to k3s
name: Build and Deploy to k3s (Production)
on:
push:
tags:
@ -16,24 +16,28 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Build Angular app
run: npm run build --prod
- name: Build Next.js app
run: npm run build
env:
NEXT_PUBLIC_API_URL: ${{ secrets.PROD_API_URL }}
- name: Build Docker image
run: |
docker build -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-prod:${{ github.sha }} .
docker tag ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-prod:${{ github.sha }} ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-prod:latest
docker build \
-t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-prod:${{ github.sha }} \
-t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-prod:latest \
--build-arg NODE_ENV=production \
.
- name: Login to Container Registry
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_URL }} -u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Push Docker image
- name: Push Docker images
run: |
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-prod:${{ github.sha }}
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-prod:latest
@ -49,19 +53,29 @@ jobs:
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
- name: Validate kubeconfig
- name: Validate kubeconfig and cluster connectivity
run: |
if ! kubectl version --client && kubectl cluster-info --kubeconfig ~/.kube/config; then
if ! kubectl version --client; then
echo "❌ Failed to get kubectl version"
exit 1
fi
if ! kubectl cluster-info --kubeconfig ~/.kube/config > /dev/null 2>&1; then
echo "❌ Failed to connect to cluster"
exit 1
fi
echo "✅ Successfully connected to Kubernetes cluster"
- name: Deploy to k3s
- name: Deploy to Production (k3s)
run: |
echo "Applying Kubernetes manifests..."
kubectl apply -k deploy/k3s/prod --kubeconfig ~/.kube/config
echo "Updating deployment image..."
kubectl set image deployment/hosting-frontend \
hosting-frontend=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/hosting-frontend-prod:${{ github.sha }} \
-n hosting --kubeconfig ~/.kube/config
kubectl rollout status deployment/hosting-frontend -n hosting --kubeconfig ~/.kube/config
echo "Waiting for rollout to complete..."
kubectl rollout status deployment/hosting-frontend -n hosting --kubeconfig ~/.kube/config --timeout=5m
echo "✅ Production deployment complete!"