rubis/.gitea/workflows/deploy-web.yml
ordinarthur 27771ed538
All checks were successful
Build & Deploy Web / build-and-deploy (push) Successful in 20s
fix(deploy/web): injecter les VITE_* env vars au build (sinon bundle invalide)
Le bundle Vite plantait au boot avec :
  Variables d'environnement invalides : { VITE_API_URL: ..., VITE_PUBLIC_LANDING_URL: ... }

Vite remplace import.meta.env.VITE_* par des literals au build time
(pas au runtime), donc l'image doit recevoir ces vars AVANT vite build.

Le Dockerfile.web accepte maintenant 3 ARGs :
- VITE_API_URL (default: https://app.rubis.arthurbarre.fr)
- VITE_PUBLIC_LANDING_URL (default: https://rubis.arthurbarre.fr)
- VITE_USE_MOCKS (default: false)

Le workflow CI les passe explicitement via build-args pour lisibilité.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 03:06:09 +02:00

85 lines
2.7 KiB
YAML

name: Build & Deploy Web
# Workflow Web (React/Vite + nginx) — sert app.rubis.arthurbarre.fr.
# Reverse-proxie /api/* vers le service ClusterIP rubis-api.
on:
push:
branches: [main]
paths:
- 'apps/web/**'
- 'packages/shared/**'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'package.json'
- 'tsconfig.base.json'
- 'turbo.json'
- 'Dockerfile.web'
- 'k3s/app/web.yml'
- '.gitea/workflows/deploy-web.yml'
env:
REGISTRY: git.arthurbarre.fr
IMAGE: ordinarthur/rubis-web
NAMESPACE: rubis
DEPLOYMENT: rubis-web
CONTAINER: web
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ordinarthur
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Web image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.web
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE }}:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE }}:cache,mode=max
# Vars Vite injectées dans le bundle au build time. Pour staging,
# créer un workflow séparé avec d'autres VITE_API_URL.
build-args: |
VITE_API_URL=https://app.rubis.arthurbarre.fr
VITE_PUBLIC_LANDING_URL=https://rubis.arthurbarre.fr
VITE_USE_MOCKS=false
- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/
- name: Deploy to K3s
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
kubectl apply -f k3s/namespace.yml
kubectl -n $NAMESPACE create secret docker-registry gitea-registry \
--docker-server=$REGISTRY \
--docker-username=ordinarthur \
--docker-password=${{ secrets.REGISTRY_PASSWORD }} \
--dry-run=client -o yaml | kubectl apply -f -
kubectl apply -f k3s/app/web.yml
kubectl -n $NAMESPACE set image deployment/$DEPLOYMENT \
$CONTAINER=$REGISTRY/$IMAGE:${{ github.sha }}
kubectl -n $NAMESPACE rollout status deployment/$DEPLOYMENT --timeout=180s