name: Deploy to Hugging Face Spaces on: push: branches: [ "main" ] jobs: build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Run Tests env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | PYTHONPATH=. pytest tests/ deploy-to-hf: needs: build-and-test runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 # Fetch all history for push - name: Push to Hugging Face Spaces env: HF_TOKEN: ${{ secrets.HF_TOKEN }} HF_USERNAME: ${{ secrets.HF_USERNAME }} HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }} run: | git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" git remote add hf https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$HF_SPACE_NAME git push -f hf main