chore: build

This commit is contained in:
Xor290
2026-09-20 12:17:57 +02:00
parent cdf03aa5b9
commit 8f4c7fa47a
2 changed files with 83 additions and 106 deletions
+44 -53
View File
@@ -1,75 +1,66 @@
name: backend-image name: ci-api
# CI pour control-plane/api (Go) : build, vet, tests, puis publication de l'image
# Docker sur push vers main.
# Construit l'image du backend (Go/Gin) et la pousse sur Docker Hub.
# - push sur main -> tags :latest et :sha-<commit>
# - tag vX.Y.Z -> tag :X.Y.Z (en plus du :sha-<commit>)
# - pull request -> build seul, rien n'est poussé
#
# Secrets à créer dans GitHub (Settings > Secrets and variables > Actions) :
# DOCKERHUB_USERNAME compte Docker Hub qui possède le dépôt d'images
# DOCKERHUB_TOKEN access token Docker Hub (droits Read & Write), jamais le mot de passe
#
# L'image est celle à renseigner dans VITRINE_BACKEND_IMAGE côté control-plane Omnex.
on: on:
push: push:
branches: [main] branches: [main]
tags: ["v*"]
paths: paths:
- "backend/**" - "backend/**"
- ".github/workflows/backend-image.yml"
pull_request: pull_request:
paths: paths:
- "backend/**" - "backend/**"
- ".github/workflows/backend-image.yml" workflow_dispatch: {}
workflow_dispatch:
permissions:
contents: read
# Un seul build par branche/tag : un nouveau push annule celui en cours.
concurrency:
group: backend-image-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE: xor1234/vitrine-backend
jobs: jobs:
build: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 20 defaults:
run:
working-directory: backend
steps: steps:
- uses: actions/checkout@v4 - name: Checkout
uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3 - name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26.0"
cache-dependency-path: backend/go.sum
# Pas de login sur les pull requests : les secrets n'y sont pas exposés - name: Vet
# (forks) et rien n'est poussé. run: go vet ./...
- name: Login Docker Hub
if: github.event_name != 'pull_request' - name: Test
run: go test ./...
- name: Build
run: go build ./...
- name: Install & run gosec
continue-on-error: true
run: |
go install github.com/securego/gosec/v2/cmd/gosec@latest
gosec ./...
- 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 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tags et labels de l'image - name: Build & push api
id: meta if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=short
type=semver,pattern={{version}}
- name: Build et push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: backend context: ./control-plane/api
file: backend/Dockerfile file: ./control-plane/api/Dockerfile
platforms: linux/amd64 push: true
push: ${{ github.event_name != 'pull_request' }} tags: |
tags: ${{ steps.meta.outputs.tags }} ${{ secrets.DOCKERHUB_USERNAME }}/vitrine-api:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=backend
cache-to: type=gha,mode=max,scope=backend
+39 -53
View File
@@ -1,75 +1,61 @@
name: frontend-image name: ci-web
# CI pour web (Vite/React) : install, typecheck, tests, build, puis publication
# de l'image Docker sur push vers main.
# Construit l'image du frontend (SPA Vite/React + nginx) et la pousse sur Docker Hub.
# - push sur main -> tags :latest et :sha-<commit>
# - tag vX.Y.Z -> tag :X.Y.Z (en plus du :sha-<commit>)
# - pull request -> build seul, rien n'est poussé
#
# Secrets à créer dans GitHub (Settings > Secrets and variables > Actions) :
# DOCKERHUB_USERNAME compte Docker Hub qui possède le dépôt d'images
# DOCKERHUB_TOKEN access token Docker Hub (droits Read & Write), jamais le mot de passe
#
# L'image est celle à renseigner dans VITRINE_FRONTEND_IMAGE côté control-plane Omnex.
on: on:
push: push:
branches: [main] branches: [main]
tags: ["v*"]
paths: paths:
- "frontend/**" - "frontend/**"
- ".github/workflows/frontend-image.yml"
pull_request: pull_request:
paths: paths:
- "frontend/**" - "frontend/**"
- ".github/workflows/frontend-image.yml" workflow_dispatch: {}
workflow_dispatch:
permissions:
contents: read
# Un seul build par branche/tag : un nouveau push annule celui en cours.
concurrency:
group: frontend-image-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE: xor1234/vitrine-frontend
jobs: jobs:
build: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 20 defaults:
run:
working-directory: web
steps: steps:
- uses: actions/checkout@v4 - name: Checkout
uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3 - name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
# Pas de login sur les pull requests : les secrets n'y sont pas exposés - name: Install dependencies
# (forks) et rien n'est poussé. run: npm ci
- name: Login Docker Hub
if: github.event_name != 'pull_request' - name: Typecheck
run: npm run typecheck
- 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 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tags et labels de l'image - name: Build & push web
id: meta if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=short
type=semver,pattern={{version}}
- name: Build et push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: frontend context: ./web
file: frontend/Dockerfile file: ./web/Dockerfile
platforms: linux/amd64 push: true
push: ${{ github.event_name != 'pull_request' }} tags: |
tags: ${{ steps.meta.outputs.tags }} ${{ secrets.DOCKERHUB_USERNAME }}/vitrine-web:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=frontend
cache-to: type=gha,mode=max,scope=frontend