diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml new file mode 100644 index 000000000..2a2654238 --- /dev/null +++ b/.github/workflows/build-images.yml @@ -0,0 +1,70 @@ +name: Build & push CRM images + +on: + push: + branches: [release] + paths: + - "apps/**" + - "packages/**" + - "package.json" + - "bun.lock" + - "turbo.json" + - ".github/workflows/build-images.yml" + workflow_dispatch: {} + +concurrency: + group: build-images-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: read + packages: write + +env: + REGISTRY: ghcr.io + # Domaine unique fige au build pour apps/app -- Next.js grave API_URL/ + # APP_URL dans le bundle client compile, pas au runtime (piege deja + # rencontre en prod le 29/08/2026, cf. docker-compose.yml sur vigiep1). + CRM_ORIGIN: https://crm.vigieproc.fr + +jobs: + build-push: + name: build-push (${{ matrix.service }}) + runs-on: ubuntu-24.04 + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + service: [api, app, agent] + + steps: + - uses: actions/checkout@v5 + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}-${{ matrix.service }} + tags: | + type=raw,value=latest + type=sha,format=short + + - uses: docker/build-push-action@v6 + with: + context: . + file: apps/${{ matrix.service }}/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + API_URL=${{ env.CRM_ORIGIN }} + APP_URL=${{ env.CRM_ORIGIN }} + cache-from: type=gha,scope=${{ matrix.service }} + cache-to: type=gha,mode=max,scope=${{ matrix.service }}