diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 083ea91..e934ac5 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -145,15 +145,50 @@ jobs: docker --version + - name: Detect UI changes + id: ui-diff + env: + FEATURE_VALIDATION: ${{ inputs.validation_level == 'feature' || contains(gitea.event.pull_request.labels.*.name, 'feature-ready') }} + BASE_SHA: ${{ gitea.event.pull_request.base.sha || gitea.event.before }} + run: | + run_ui=true + reason="no reliable base revision; checking UI conservatively" + + if [ "$FEATURE_VALIDATION" = "true" ]; then + reason="feature validation requested" + elif [[ ! "$BASE_SHA" =~ ^([0-9a-fA-F]{40}|[0-9a-fA-F]{64})$ ]] || [[ "$BASE_SHA" =~ ^0+$ ]]; then + : # Keep the conservative default when the event has no usable base. + else + if ! git cat-file -e "$BASE_SHA^{commit}" 2>/dev/null; then + git fetch --no-tags --depth=1 origin "$BASE_SHA" >/dev/null 2>&1 || true + fi + if git cat-file -e "$BASE_SHA^{commit}" 2>/dev/null && git diff --quiet "$BASE_SHA" HEAD -- apps/ui/ crank-community.png; then + run_ui=false + reason="UI inputs are unchanged from the event base" + else + reason="apps/ui changed or the base comparison was unavailable" + fi + fi + + echo "run_ui=$run_ui" >> "$GITHUB_OUTPUT" + if [ "$run_ui" = "false" ]; then + echo "UI checks not applicable: $reason." + else + echo "Running UI checks: $reason." + fi + - name: Install UI dependencies + if: steps.ui-diff.outputs.run_ui == 'true' working-directory: apps/ui run: npm ci - name: Audit UI dependencies + if: steps.ui-diff.outputs.run_ui == 'true' working-directory: apps/ui run: npm audit --audit-level=high - name: Build UI bundle + if: steps.ui-diff.outputs.run_ui == 'true' working-directory: apps/ui run: npm run build