diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d7b859..3211a5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,15 +3,6 @@ name: CI on: pull_request: branches: [ master ] - paths: - - "src/**" - - "scripts/**" - - "angular.json" - - "tsconfig*.json" - - "package.json" - - "package-lock.json" - - ".github/workflows/**" - - "public/i18n/**" jobs: build: @@ -19,18 +10,52 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Detect relevant changes + id: changes + shell: bash + run: | + BASE="${{ github.event.pull_request.base.sha }}" + HEAD="${{ github.sha }}" + + echo "Base: $BASE" + echo "Head: $HEAD" + + files="$(git diff --name-only "$BASE" "$HEAD")" + echo "Changed files:" + echo "$files" + + if echo "$files" | grep -Eq '^(src/|scripts/|angular\.json$|tsconfig.*\.json$|package\.json$|package-lock\.json$|\.github/workflows/|public/i18n/)'; then + echo "run_build=true" >> "$GITHUB_OUTPUT" + else + echo "run_build=false" >> "$GITHUB_OUTPUT" + fi + + - name: Skip build (no relevant changes) + if: steps.changes.outputs.run_build != 'true' + run: | + echo "No files changed that affect the build/tests. Marking CI as successful." + exit 0 - name: Setup Node + if: steps.changes.outputs.run_build == 'true' uses: actions/setup-node@v4 with: node-version: 24.13.0 cache: npm - - run: npm i -g npm@11.8.0 - - run: npm --version + - name: Pin npm version + if: steps.changes.outputs.run_build == 'true' + run: | + npm i -g npm@11.8.0 + npm --version - name: Install dependencies + if: steps.changes.outputs.run_build == 'true' run: npm ci - name: Build + if: steps.changes.outputs.run_build == 'true' run: npm run build --if-present