diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 353f3fd..f88b7a0 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,17 +1,18 @@ -name: Build Project +name: Build & Deploy + on: push: - branches: [main, master] + branches: [main] pull_request: - branches: [main, master] + branches: [main] jobs: build: - runs-on: linux # Doit correspondre à GITEA_RUNNER_LABELS (ex: linux:docker,dind) - container: node:24 # Utilise l'image officielle Node.js 24 + runs-on: linux + container: node:24 steps: - name: Checkout repository - uses: actions/checkout@v4 # Action Gitea pour checkout + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -19,4 +20,37 @@ jobs: run: npm ci - name: Build project - run: npm run build \ No newline at end of file + run: npm run build + + docker: + needs: build + runs-on: linux + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: http://192.168.1.39:3000 + username: ${{ secrets.GITEA_USERNAME }} + password: ${{ secrets.GITEA_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + 192.168.1.39:3000/username/pc-builder:latest + 192.168.1.39:3000/username/pc-builder:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Trigger deploy + run: | + curl -X POST http://192.168.1.39:9000/deploy || echo "Deploy webhook not reachable"