From 38a6851b461f83ae742885c623759bdfa31bb991 Mon Sep 17 00:00:00 2001 From: Tarik Moussa Date: Sun, 14 Jun 2026 08:19:01 +0200 Subject: [PATCH] feat(cd): auto-deploy ci-ai-bot on push + dehard-code Jetson URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - .gitea/workflows/cd.yml: on push to main (bot/** or scripts/**), build ci-ai-bot:latest on the Pi runner via DooD and force-recreate the container with docker compose (no registry push needed) - reusable-{ai-review,commands,security}.yml: replace hardcoded 192.168.178.103:11434 with ${{ vars.JETSON_OLLAMA_URL }} (org variable set in conformallab → fallback to old IP if variable is missing) Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/cd.yml | 46 +++++++++++++++++++++++++ .gitea/workflows/reusable-ai-review.yml | 3 +- .gitea/workflows/reusable-commands.yml | 3 +- .gitea/workflows/reusable-security.yml | 3 +- 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 .gitea/workflows/cd.yml diff --git a/.gitea/workflows/cd.yml b/.gitea/workflows/cd.yml new file mode 100644 index 0000000..13f2423 --- /dev/null +++ b/.gitea/workflows/cd.yml @@ -0,0 +1,46 @@ +# CD — rebuild and restart ci-ai-bot on the Pi whenever bot/ or scripts/ change. +# +# How it works (Docker-out-of-Docker): +# 1. Job runs in docker:cli on the Pi runner (eulernest label). +# 2. Mounts the HOST docker socket → builds the new image directly in the host +# Docker daemon (no registry push needed — image is already local). +# 3. Mounts /mnt/external:ro → runs `docker compose up --force-recreate` +# which picks up the freshly built image and recreates the container. +# +# Prerequisite (one-time): +# - Runner config must list /var/run/docker.sock and /mnt/external in valid_volumes +# (set in ansible-eulernest roles/gitea_runner/templates/config.yaml.j2). +# - Set org variable JETSON_OLLAMA_URL in conformallab → Actions → Variables: +# value = http://192.168.178.103:11434/v1 +name: CD — ci-ai-bot + +on: + push: + branches: [main] + paths: + - "bot/**" + - "scripts/**" + +jobs: + deploy: + runs-on: eulernest + container: + image: docker:27-cli + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /mnt/external:/mnt/external:ro + + steps: + - uses: actions/checkout@v4 + + - name: Build ci-ai-bot image + # Build from repo root so bot/Dockerfile can COPY scripts/ + run: docker build -t ci-ai-bot:latest -f bot/Dockerfile . + + - name: Recreate ci-ai-bot container + # --force-recreate: always replace the container even if config is unchanged, + # so the freshly built image is picked up. + run: | + docker compose \ + -f /mnt/external/docker-compose.yml \ + up -d --no-deps --force-recreate ci-ai-bot diff --git a/.gitea/workflows/reusable-ai-review.yml b/.gitea/workflows/reusable-ai-review.yml index 0012434..1618d6e 100644 --- a/.gitea/workflows/reusable-ai-review.yml +++ b/.gitea/workflows/reusable-ai-review.yml @@ -30,7 +30,8 @@ jobs: env: AI_PROVIDER: ollama AI_MODEL: coder - AI_BASE_URL: http://192.168.178.103:11434/v1 + # JETSON_OLLAMA_URL: org variable in conformallab → Actions → Variables + AI_BASE_URL: ${{ vars.JETSON_OLLAMA_URL || 'http://192.168.178.103:11434/v1' }} GITEA_TOKEN: ${{ github.token }} GITEA_API: https://git.eulernest.eu/api/v1 run: python /opt/ci-ai/scripts/ai_review.py diff --git a/.gitea/workflows/reusable-commands.yml b/.gitea/workflows/reusable-commands.yml index f70c537..aebb10e 100644 --- a/.gitea/workflows/reusable-commands.yml +++ b/.gitea/workflows/reusable-commands.yml @@ -22,7 +22,8 @@ jobs: env: AI_PROVIDER: ollama AI_MODEL: coder - AI_BASE_URL: http://192.168.178.103:11434/v1 + # JETSON_OLLAMA_URL: org variable in conformallab → Actions → Variables + AI_BASE_URL: ${{ vars.JETSON_OLLAMA_URL || 'http://192.168.178.103:11434/v1' }} GITEA_TOKEN: ${{ github.token }} GITEA_API: https://git.eulernest.eu/api/v1 steps: diff --git a/.gitea/workflows/reusable-security.yml b/.gitea/workflows/reusable-security.yml index 5311edd..bfd354a 100644 --- a/.gitea/workflows/reusable-security.yml +++ b/.gitea/workflows/reusable-security.yml @@ -73,7 +73,8 @@ jobs: env: AI_PROVIDER: ollama AI_MODEL: coder - AI_BASE_URL: http://192.168.178.103:11434/v1 + # JETSON_OLLAMA_URL: org variable in conformallab → Actions → Variables + AI_BASE_URL: ${{ vars.JETSON_OLLAMA_URL || 'http://192.168.178.103:11434/v1' }} GITEA_TOKEN: ${{ github.token }} GITEA_API: https://git.eulernest.eu/api/v1 run: |