From c174d671d323e99a00b307e19ac99bdb941d480e Mon Sep 17 00:00:00 2001 From: Leon Morival Date: Sun, 17 May 2026 15:33:35 +0200 Subject: [PATCH] feat: deploy --- .gitea/workflows/deploy.yml | 196 +++++++++++------------------------- 1 file changed, 61 insertions(+), 135 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 76970f9..e5f444d 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,144 +1,70 @@ -services: - app: - image: gitea.leonmorival.com/leon-morival/bemeal-api:latest - container_name: bemeal-app - restart: unless-stopped +name: Laravel CI-CD - depends_on: - pgsql: - condition: service_healthy - redis: - condition: service_started +on: + push: + branches: ["main"] + +env: + REGISTRY: gitea.leonmorival.com + IMAGE_NAME: daily_meal/bemeal-api + +jobs: + + # ========================= + # TESTS + # ========================= + test: + name: Tests Unitaires + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP container tests + run: | + docker run --rm \ + -v $PWD:/app \ + -w /app \ + laravelsail/php84-composer:latest \ + bash -c "composer install --no-interaction --ignore-platform-req=ext-intl && php artisan test" - environment: - APP_NAME: "BeMeal" - APP_ENV: production - APP_DEBUG: "false" - APP_KEY: ${APP_KEY} - APP_URL: ${APP_URL} + # ========================= + # BUILD & PUSH IMAGE + # ========================= + build: + name: Build & Push Docker + needs: test + runs-on: ubuntu-latest - APP_LOCALE: fr + steps: + - name: Checkout + uses: actions/checkout@v4 - SERVER_NAME: ":80" - APP_RUNTIME: "Laravel\\FrankenPHP\\Runtime" + - name: Login to Gitea Registry + run: | + echo "${{ secrets.TOKEN_GITEA }}" \ + | docker login $REGISTRY \ + -u "${{ github.actor }}" \ + --password-stdin - DB_CONNECTION: pgsql - DB_HOST: pgsql - DB_PORT: 5432 - DB_DATABASE: ${DB_DATABASE} - DB_USERNAME: ${DB_USERNAME} - DB_PASSWORD: ${DB_PASSWORD} - - REDIS_HOST: redis - REDIS_CLIENT: predis - QUEUE_CONNECTION: redis - - SCOUT_DRIVER: meilisearch - MEILISEARCH_HOST: http://meilisearch:7700 - MEILISEARCH_KEY: ${MEILISEARCH_KEY} - - volumes: - - bemeal_storage:/var/www/html/storage/app - - bemeal_public:/var/www/html/storage/app/public - - networks: - - nginx - - internal - - horizon: - image: gitea.leonmorival.com/leon-morival/bemeal-api:latest - container_name: bemeal-horizon - restart: unless-stopped - - command: php artisan horizon - - depends_on: - pgsql: - condition: service_healthy - redis: - condition: service_started - - environment: - APP_ENV: production - APP_KEY: ${APP_KEY} - - DB_CONNECTION: pgsql - DB_HOST: pgsql - DB_PORT: 5432 - DB_DATABASE: ${DB_DATABASE} - DB_USERNAME: ${DB_USERNAME} - DB_PASSWORD: ${DB_PASSWORD} - - REDIS_HOST: redis - REDIS_CLIENT: predis - QUEUE_CONNECTION: redis - - volumes: - - bemeal_storage:/var/www/html/storage/app - - networks: - - internal + - name: Build Docker image + run: | + IMAGE=$REGISTRY/$IMAGE_NAME:latest + docker build -t $IMAGE . + docker push $IMAGE - pgsql: - image: postgres:15-alpine - container_name: bemeal-pgsql - restart: unless-stopped + # ========================= + # DEPLOY + # ========================= + deploy: + name: Deploy via Portainer + needs: build + runs-on: ubuntu-latest - environment: - POSTGRES_DB: ${DB_DATABASE} - POSTGRES_USER: ${DB_USERNAME} - POSTGRES_PASSWORD: ${DB_PASSWORD} - - healthcheck: - test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE}"] - interval: 5s - timeout: 5s - retries: 10 - - volumes: - - bemeal_pgsql:/var/lib/postgresql/data - - networks: - - internal - - redis: - image: redis:alpine - container_name: bemeal-redis - restart: unless-stopped - - volumes: - - bemeal_redis:/data - - networks: - - internal - - meilisearch: - image: getmeili/meilisearch:latest - container_name: bemeal-meilisearch - restart: unless-stopped - - environment: - MEILI_NO_ANALYTICS: "true" - MEILI_MASTER_KEY: ${MEILISEARCH_KEY} - - volumes: - - bemeal_meili:/meili_data - - networks: - - internal - -volumes: - bemeal_pgsql: - bemeal_redis: - bemeal_storage: - bemeal_public: - bemeal_meili: - -networks: - nginx: - external: true - - internal: - driver: bridge + steps: + - name: Trigger Portainer webhook + run: | + curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}"