| name: test-and-deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: python -m pip install --upgrade pip && pip install -r requirements.txt | |
| - name: Run pytest | |
| run: pytest | |
| deploy: | |
| needs: test | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install deployment dependency | |
| run: python -m pip install --upgrade pip && pip install huggingface-hub | |
| - name: Deploy to Hugging Face Spaces | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| HF_SPACE_REPO: ${{ secrets.HF_SPACE_REPO }} | |
| run: python scripts/deploy_to_hf_spaces.py | |