From 4b6232d2ba2e4dbd1b21f93326479f40d59b2c82 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 20 Jun 2026 19:16:38 -0400 Subject: [PATCH] ci: add Gitea CI/CD workflow for React web client Pipeline includes lint (eslint), build (tsc + vite), and manual deploy stages. --- .gitea/workflows/build.yml | 116 +++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .gitea/workflows/build.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..99ada5c --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,116 @@ +# Gitea CI/CD for alrahma_web_client (React + Vite + TypeScript) +# +# Triggers: +# - Push to any branch +# - Pull requests +# - Tags +# +# Stages: lint → build → deploy (manual) + +name: Web Client CI/CD + +on: + push: + branches: [main, master, develop, 'feature/**', 'fix/**'] + pull_request: + branches: [main, master, develop] + push: + tags: ['v*'] + +env: + CI: true + +jobs: + # ────────────────────────────────────────────── + # LINT: ESLint with TypeScript + # ────────────────────────────────────────────── + lint: + name: Lint (ESLint + TypeScript) + runs-on: ubuntu-latest + container: + image: node:22-alpine + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache npm dependencies + uses: actions/cache@v4 + with: + path: node_modules/ + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - name: Install dependencies + run: npm ci --no-audit --no-fund + + - name: Run ESLint + run: npm run lint + + # ────────────────────────────────────────────── + # BUILD: TypeScript + Vite + # ────────────────────────────────────────────── + build: + name: Build (tsc + Vite) + runs-on: ubuntu-latest + container: + image: node:22-alpine + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache npm dependencies + uses: actions/cache@v4 + with: + path: node_modules/ + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - name: Install dependencies + run: npm ci --no-audit --no-fund + + - name: Build project + run: npm run build + env: + VITE_API_ORIGIN: ${{ vars.VITE_API_ORIGIN || '' }} + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + retention-days: 7 + + # ────────────────────────────────────────────── + # DEPLOY (manual): to shared hosting via SSH + # ────────────────────────────────────────────── + deploy: + name: Deploy to production + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/develop' + needs: [lint, build] + environment: + name: production + url: ${{ vars.PRODUCTION_URL }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Install SSH client + run: | + apk add --no-cache openssh-client sshpass rsync + + - name: Deploy via rsync + run: | + sshpass -p "${{ secrets.SSH_PASSWORD }}" rsync -avz --delete \ + -e "ssh -p ${{ vars.SSH_PORT || 22 }} -o StrictHostKeyChecking=no" \ + --exclude='.htaccess' \ + ./dist/ \ + ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ vars.SSH_TARGET_DIR }}/