Files
template-vitrine/.github/workflows/frontend-image.yml
T

62 lines
1.5 KiB
YAML

name: ci-web
# CI pour le frontend (Vite/React) : install, lint, build, puis publication
# de l'image Docker sur push vers main.
on:
push:
branches: [main]
paths:
- "frontend/**"
pull_request:
paths:
- "frontend/**"
workflow_dispatch: {}
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Set up Docker Buildx
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & push web
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/vitrine-web:latest