name: CI on: push: branches: [main, master] pull_request: branches: [main, master] env: GITEA_URL: https://git.home.ms jobs: lint: runs-on: ubuntu-latest container: image: node:20-bookworm steps: - name: Clone repo run: | rm -rf $GITHUB_WORKSPACE/* git clone --depth 1 $GITEA_URL/$GITHUB_REPOSITORY $GITHUB_WORKSPACE git -C $GITHUB_WORKSPACE checkout $GITHUB_SHA 2>/dev/null || true - name: Run npm lint (JS/TS) if: always() run: | if [[ -f package.json ]]; then npm ci npm run lint --if-present || true else echo "No Node.js project detected, skipping npm lint" fi test: runs-on: ubuntu-latest container: image: node:20-bookworm steps: - name: Clone repo run: | rm -rf $GITHUB_WORKSPACE/* git clone --depth 1 $GITEA_URL/$GITHUB_REPOSITORY $GITHUB_WORKSPACE git -C $GITHUB_WORKSPACE checkout $GITHUB_SHA 2>/dev/null || true - name: Install dependencies run: npm ci - name: Run tests with coverage run: npm test docker-build: runs-on: ubuntu-latest steps: - name: Clone repo run: | rm -rf $GITHUB_WORKSPACE/* git clone --depth 1 $GITEA_URL/$GITHUB_REPOSITORY $GITHUB_WORKSPACE git -C $GITHUB_WORKSPACE checkout $GITHUB_SHA 2>/dev/null || true - name: Build Docker image if: always() run: | if [[ -f Dockerfile ]]; then docker build -t $GITHUB_REPOSITORY:test . else echo "No Dockerfile found, skipping docker build" fi security: runs-on: ubuntu-latest container: image: node:20-bookworm steps: - name: Clone repo run: | rm -rf $GITHUB_WORKSPACE/* git clone --depth 1 $GITEA_URL/$GITHUB_REPOSITORY $GITHUB_WORKSPACE git -C $GITHUB_WORKSPACE checkout $GITHUB_SHA 2>/dev/null || true - name: Run npm audit (JS/TS) if: always() run: | if [[ -f package.json ]]; then npm ci npm audit --audit-level=high 2>/dev/null || echo "npm audit: vulnerabilities found (non-blocking)" else echo "No Node.js project detected, skipping npm audit" fi build-result: needs: [lint, test, docker-build, security] runs-on: ubuntu-latest if: always() steps: - name: Summary run: echo "All CI checks completed"