diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 2388b1e..d6fb9c9 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -91,24 +91,6 @@ jobs: -d "parse_mode=Markdown" || true fi - - name: Pack web artifact for deploy - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - working-directory: memento-note - run: | - tar czf ../web-artifact.tgz \ - .next/standalone .next/static public prisma \ - node_modules/.prisma node_modules/@prisma node_modules/prisma \ - docker-entrypoint.sh socket-server.ts tsconfig.json - ls -lh ../web-artifact.tgz - - - name: Upload web artifact - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - uses: actions/upload-artifact@v3 - with: - name: web-artifact - path: web-artifact.tgz - retention-days: 2 - deploy: name: Deploy production (on server) needs: ci @@ -123,10 +105,32 @@ jobs: git fetch origin main git reset --hard origin/main - - name: Download web artifact - uses: actions/download-artifact@v3 + # Build sur docker-host : évite upload-artifact Gitea (souvent cassé en prod). + - name: Setup Node 22 + uses: actions/setup-node@v4 with: - name: web-artifact + node-version: "22" + + - name: Build web artifact on server + working-directory: /opt/memento/memento-note + run: | + set -euo pipefail + npm ci --legacy-peer-deps + npx prisma generate + npm run build + for p in .next/standalone .next/static public prisma; do + [ -e "$p" ] || { echo "Missing build output: $p"; exit 1; } + done + tar czf /tmp/web-artifact.tgz \ + .next/standalone .next/static public prisma \ + node_modules/.prisma node_modules/@prisma node_modules/prisma \ + docker-entrypoint.sh socket-server.ts tsconfig.json + SIZE=$(stat -c%s /tmp/web-artifact.tgz) + if [ "$SIZE" -lt 1048576 ]; then + echo "ERROR: artifact too small ($SIZE bytes)" + exit 1 + fi + ls -lh /tmp/web-artifact.tgz - name: Update .env.docker env: @@ -238,6 +242,6 @@ jobs: - name: Deploy on 192.168.1.190 env: - ARTIFACT_TGZ: ${{ github.workspace }}/web-artifact.tgz + ARTIFACT_TGZ: /tmp/web-artifact.tgz EXPECTED_COMMIT: ${{ github.sha }} run: bash /opt/memento/scripts/deploy-prod.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c9bce17..0cc816c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -91,25 +91,6 @@ jobs: -d "parse_mode=Markdown" || true fi - - name: Pack web artifact for deploy - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - working-directory: memento-note - run: | - tar czf ../web-artifact.tgz \ - .next/standalone .next/static public prisma \ - node_modules/.prisma node_modules/@prisma node_modules/prisma \ - docker-entrypoint.sh socket-server.ts tsconfig.json - ls -lh ../web-artifact.tgz - - - name: Upload web artifact - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - uses: actions/upload-artifact@v3 - continue-on-error: true - with: - name: web-artifact - path: web-artifact.tgz - retention-days: 2 - deploy: name: Deploy production (on server) needs: ci @@ -124,11 +105,31 @@ jobs: git fetch origin main git reset --hard origin/main - - name: Download web artifact - uses: actions/download-artifact@v3 - continue-on-error: true + - name: Setup Node 22 + uses: actions/setup-node@v4 with: - name: web-artifact + node-version: "22" + + - name: Build web artifact on server + working-directory: /opt/memento/memento-note + run: | + set -euo pipefail + npm ci --legacy-peer-deps + npx prisma generate + npm run build + for p in .next/standalone .next/static public prisma; do + [ -e "$p" ] || { echo "Missing build output: $p"; exit 1; } + done + tar czf /tmp/web-artifact.tgz \ + .next/standalone .next/static public prisma \ + node_modules/.prisma node_modules/@prisma node_modules/prisma \ + docker-entrypoint.sh socket-server.ts tsconfig.json + SIZE=$(stat -c%s /tmp/web-artifact.tgz) + if [ "$SIZE" -lt 1048576 ]; then + echo "ERROR: artifact too small ($SIZE bytes)" + exit 1 + fi + ls -lh /tmp/web-artifact.tgz - name: Update .env.docker env: @@ -229,6 +230,6 @@ jobs: - name: Deploy on 192.168.1.190 env: - ARTIFACT_TGZ: ${{ github.workspace }}/web-artifact.tgz + ARTIFACT_TGZ: /tmp/web-artifact.tgz EXPECTED_COMMIT: ${{ github.sha }} run: bash /opt/memento/scripts/deploy-prod.sh