name: Sync Ari Shopping Catalog
on:
  workflow_dispatch:
  schedule:
    - cron: '@daily'
jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - run: python3 -m pip install --user -r workloads/ecommerce/tools/requirements.txt
      - run: python3 workloads/ecommerce/tools/catalog_sync.py --source workloads/ecommerce/catalog-source.csv --download-images
      - run: |
          git config user.name "Ari Shopping Catalog Bot"
          git config user.email "catalog-bot@cruzcloud.net"
          git add workloads/ecommerce/data/products.json workloads/ecommerce/assets/img/products
          git diff --cached --quiet && exit 0
          git commit -m "chore(catalog): sync products"
          git pull --rebase origin main
          git push origin HEAD:main
