From 9f230ffcc9780fd4b6a8f342751349f6b0f5a277 Mon Sep 17 00:00:00 2001 From: L HEREEC Kevin INNOV/PTFM Date: Mon, 13 Jul 2026 11:17:44 +0200 Subject: [PATCH] ci: add Gitea Actions workflow and docker-compose.prod.yml for NAS deployment --- .gitea/workflows/build.yml | 70 ++++++++++++++++++++++++++++++++++++++ docker-compose.prod.yml | 52 ++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .gitea/workflows/build.yml create mode 100644 docker-compose.prod.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..5927f08 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,70 @@ +name: Build & Deploy + +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +jobs: + build: + runs-on: linux + container: node:24-alpine + steps: + - name: Checkout repository + run: git clone --depth=1 http://x-access-token:${{ github.token }}@192.168.1.39:3000/${{ github.repository }}.git . + + - name: Install dependencies + run: npm ci + + - name: Run build + run: node ace build + + docker: + needs: build + runs-on: dind + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') + steps: + - name: Checkout repository + run: git clone --depth=1 http://x-access-token:${{ github.token }}@192.168.1.39:3000/${{ github.repository }}.git . + + - name: Login to Gitea Container Registry + run: | + echo "${{ secrets.GITEA_TOKEN }}" | docker login http://192.168.1.39:3000 -u "${{ secrets.GITEA_USERNAME }}" --password-stdin + + - name: Build and push Docker image + run: | + IMAGE=192.168.1.39:3000/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') + docker build -t ${IMAGE}:latest -t ${IMAGE}:${{ github.sha }} . + docker push ${IMAGE}:latest + docker push ${IMAGE}:${{ github.sha }} + + - name: Deploy on NAS + run: | + apk add --no-cache openssh-client sshpass + + # Copier docker-compose.prod.yml sur le NAS + cat docker-compose.prod.yml | sshpass -p "${{ secrets.NASPASS }}" ssh -o StrictHostKeyChecking=no Stude12@192.168.1.39 \ + "mkdir -p /volume1/docker/adam-acs && cat > /volume1/docker/adam-acs/docker-compose.prod.yml" + + # Créer le fichier .env sur le NAS à partir des secrets + sshpass -p "${{ secrets.NASPASS }}" ssh -o StrictHostKeyChecking=no Stude12@192.168.1.39 "cat > /volume1/docker/adam-acs/.env" <{process.exit(r.ok?0:1)}).catch(()=>process.exit(1))"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 15s + +volumes: + mongo_data: + app_tr069_data: + app_tr069_logs: