name: Patterns Artifact

on:
  push:
    paths:
      - "data/patterns/**" # Trigger only on changes to files in the patterns folder

jobs:
  zip-and-upload:
    name: Zip and Upload Patterns Folder
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Verify Changes in Patterns Folder
        id: check-changes
        run: |
          git fetch origin
          if git diff --quiet HEAD~1 -- data/patterns; then
            echo "No changes detected in patterns folder."
            echo "changes=false" >> $GITHUB_OUTPUT
          else
            echo "Changes detected in patterns folder."
            echo "changes=true" >> $GITHUB_OUTPUT
          fi
      - name: Zip the Patterns Folder
        if: steps.check-changes.outputs.changes == 'true'
        run: zip -r patterns.zip data/patterns/

      - name: Upload Patterns Artifact
        if: steps.check-changes.outputs.changes == 'true'
        uses: actions/upload-artifact@v6
        with:
          name: patterns
          path: patterns.zip
