diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38c0d8a3..b4313bd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,45 @@ jobs: - run: npm test - run: npm run build + changes: + name: Detect docs-only change + runs-on: ubuntu-latest + outputs: + app: ${{ steps.filter.outputs.app }} + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + fetch-depth: 0 + - id: filter + name: Check whether anything outside site/ changed + shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + BASE_REF: ${{ github.base_ref }} + BEFORE_SHA: ${{ github.event.before }} + run: | + if [ "$EVENT_NAME" = "pull_request" ]; then + base="origin/$BASE_REF" + else + base="$BEFORE_SHA" + fi + if ! files=$(git diff --name-only "$base"...HEAD 2>/dev/null); then + echo "Could not compare with $base; running everything." + echo "app=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + if printf '%s\n' "$files" | grep -qvE '^site/'; then + echo "app=true" >> "$GITHUB_OUTPUT" + else + echo "Only site/ changed; the native builds are skipped." + echo "app=false" >> "$GITHUB_OUTPUT" + fi + native: + # Docs-only changes skip the native builds. A skipped job still satisfies + # the required status check, so such pull requests can merge. + needs: changes + if: needs.changes.outputs.app == 'true' strategy: fail-fast: false matrix: