name: Get Leptos Changed Call

on:
  workflow_call:
    outputs:
      leptos_changed:
        description: "Leptos Changed"
        value: ${{ jobs.create.outputs.leptos_changed }}

jobs:
  create:
    name: Detect Source Change
    runs-on: ubuntu-latest
    outputs:
      leptos_changed: ${{ steps.set-source-changed.outputs.leptos_changed }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Get source files that changed
        id: changed-source
        uses: tj-actions/changed-files@v36
        with:
          files: |
            integrations
            leptos
            leptos_config
            leptos_dom
            leptos_hot_reload
            leptos_macro
            leptos_reactive
            leptos_server
            meta
            router
            server_fn
            server_fn_macro

      - name: List source files that changed
        run: echo '${{ steps.changed-source.outputs.all_changed_files }}'

      - name: Set leptos_changed
        id: set-source-changed
        run: |
          echo "leptos_changed=${{ steps.changed-source.outputs.any_changed }}" >> "$GITHUB_OUTPUT"
