From 6ea793de877742eecf302b018740cffd30611471 Mon Sep 17 00:00:00 2001 From: Youssef Date: Tue, 23 Jun 2026 01:16:45 +0200 Subject: [PATCH] =?UTF-8?q?ci(gitea):=20s=C3=A9paration=20des=20pipelines?= =?UTF-8?q?=20test=20et=20prod=20en=20deux=20fichiers=20distincts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/{ci.yml => ci-prod.yml} | 30 +------------ .gitea/workflows/ci-test.yml | 56 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 28 deletions(-) rename .gitea/workflows/{ci.yml => ci-prod.yml} (65%) create mode 100644 .gitea/workflows/ci-test.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci-prod.yml similarity index 65% rename from .gitea/workflows/ci.yml rename to .gitea/workflows/ci-prod.yml index 80b5778..11f02f0 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci-prod.yml @@ -1,15 +1,14 @@ -name: AS Talange CI/CD Pipeline +name: AS Talange CI/CD Pipeline - Production on: push: branches: - - main - 'prod/*' jobs: test: name: Build & Run Unit Tests - runs-on: [self-hosted, ubuntu-latest] + runs-on: [self-hosted, prod] container: image: maven:3.9.6-eclipse-temurin-21 steps: @@ -27,32 +26,7 @@ jobs: - name: Run Maven Tests run: mvn clean test - deploy_test: - name: Deploy to Test Environment - needs: test - if: github.ref == 'refs/heads/main' - runs-on: [self-hosted, ubuntu-latest] - container: - image: docker:latest - steps: - - name: Clone repository - run: | - apk add --no-cache git - SERVER_URL="${{ github.server_url }}" - SERVER_NO_PROTO="${SERVER_URL#http://}" - SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}" - git clone --depth 1 "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" . - git checkout ${{ github.sha }} - - name: Deploy with Docker Compose - env: - DB_USER: ${{ secrets.DB_USER }} - DB_PASSWORD: ${{ secrets.DB_PASSWORD }} - run: | - echo "POSTGRES_USER=${DB_USER:-myuser}" > .env - echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env - docker compose down app || true - docker compose up -d --build app deploy_prod: name: Deploy to Prod Environment diff --git a/.gitea/workflows/ci-test.yml b/.gitea/workflows/ci-test.yml new file mode 100644 index 0000000..fd71852 --- /dev/null +++ b/.gitea/workflows/ci-test.yml @@ -0,0 +1,56 @@ +name: AS Talange CI/CD Pipeline + +on: + push: + branches: + - main + +jobs: + test: + name: Build & Run Unit Tests + runs-on: [self-hosted, ubuntu-latest] + container: + image: maven:3.9.6-eclipse-temurin-21 + steps: + - name: Clone repository + run: | + if ! command -v git &> /dev/null; then + apt-get update && apt-get install -y git + fi + SERVER_URL="${{ github.server_url }}" + SERVER_NO_PROTO="${SERVER_URL#http://}" + SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}" + git clone --depth 1 "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" . + git checkout ${{ github.sha }} + + - name: Run Maven Tests + run: mvn clean test + + deploy_test: + name: Deploy to Test Environment + needs: test + if: github.ref == 'refs/heads/main' + runs-on: [self-hosted, ubuntu-latest] + container: + image: docker:latest + steps: + - name: Clone repository + run: | + apk add --no-cache git + SERVER_URL="${{ github.server_url }}" + SERVER_NO_PROTO="${SERVER_URL#http://}" + SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}" + git clone --depth 1 "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" . + git checkout ${{ github.sha }} + + - name: Deploy with Docker Compose + env: + DB_USER: ${{ secrets.DB_USER }} + DB_PASSWORD: ${{ secrets.DB_PASSWORD }} + run: | + echo "POSTGRES_USER=${DB_USER:-myuser}" > .env + echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env + docker compose down app || true + docker compose up -d --build app + +