# .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 # *** KEY CHANGE *** # Changed the shell from 'pwsh' to 'powershell' to use the default # Windows PowerShell, which should be available on your 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 } # The activation command is different for PowerShell .\.venv\Scripts\Activate.ps1 # Step 4: Install or update dependencies - name: Install dependencies run: | # The venv is now active for this shell session, so we can call pip directly. pip install --upgrade pip pip install -r requirements.txt # Step 5: Run the indexing script within the virtual environment - name: Run indexing script run: | # Call python directly, as the correct one is now on the PATH from the activated venv. python create_index.py env: GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Optional: Specify the working directory if your bot lives in a subfolder # working-directory: ./path/to/your/bot