name: analytics | Update Cognee Stats Daily

on:
  schedule:
    - cron: '0 1 * * *'  # Runs every day at 01:00 UTC

jobs:
  update_stats:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3
        with:
          persist-credentials: false

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'

      - name: Install Dependencies
        run: |
          pip install requests posthog

      - name: Run Update Script
        env:
          POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
          POSTHOG_API_HOST: ${{ secrets.POSTHOG_API_HOST }}
        run: |
          cd tools  # Change to the 'tools' directory
          echo "Current working directory after changing to tools:"
          pwd  # Print the working directory again
          echo "List of folders in the tools directory:"
          ls -la  # List all files and folders in the 'tools' directory
          python daily_pypi_downloads.py  # Run the script