name: Deploy to Hugging Face Space on: push: branches: - main workflow_dispatch: jobs: test: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install dependencies run: pip install -r requirements-dev.txt - name: Install Playwright's Chromium run: playwright install --with-deps chromium - name: Lint run: ruff check . - name: Run tests run: pytest deploy: needs: test runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Push to Hugging Face Space env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git remote add space https://hf-actions-bot:${HF_TOKEN}@huggingface.co/spaces/OrganizedProgrammers/SERPent # Fetch first so --force-with-lease has a remote-tracking ref to # compare against - without this it either fails every run or # (depending on git version) silently behaves like plain --force. # This makes the push fail instead of silently overwriting anyone # else who deployed to this same Space since our last fetch. git fetch space main git push --force-with-lease space HEAD:main