# .github/workflows/reindex_on_merge.yml name: Re-index Repository on Merge (Self-Hosted) on: pull_request: types: [closed] branches: - main workflow_dispatch: jobs: reindex: # This condition ensures the job only runs if the pull request was actually merged. if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' runs-on: Windows # Set the default shell to PowerShell, which is native to your Windows runner. defaults: run: shell: powershell steps: # Step 1: Check out the repository's code - name: Checkout repository uses: actions/checkout@v4 # Step 2: Set up a specific Python version - name: Set up Python 3.11 id: setup-python uses: actions/setup-python@v4 with: python-version: '3.11' # Step 3: Create and activate a virtual environment (using PowerShell syntax) - name: Create and activate virtual environment run: | if (-not (Test-Path -Path ".venv")) { python -m venv .venv } .\.venv\Scripts\Activate.ps1 # Step 4: Install or update dependencies - name: Install dependencies run: | pip install --upgrade pip pip install -r requirements.txt # Step 5: *** NEW - GPU Diagnostics *** # This step will help us see if the runner can access the GPU and CUDA. - name: Check GPU and CUDA status run: | echo "--- Checking for nvidia-smi ---" # The '|| $true' part ensures the workflow doesn't fail if the command isn't found nvidia-smi || $true echo "--- Checking PyTorch CUDA availability ---" # This command will explicitly tell us if PyTorch can see the GPU. python -c "import torch; print(f'PyTorch version: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}'); print(f'CUDA version: {torch.version.cuda}'); print(f'Device count: {torch.cuda.device_count()}')" # Step 6: Run the indexing script within the virtual environment - name: Run indexing script run: | python create_index.py env: GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Step 7: Upload the database as an artifact - name: Upload database artifact uses: actions/upload-artifact@v4 with: name: chroma_db_artifact path: ./chroma_db