| name: CI/CD - Tests + Déploiement Hugging Face Space | |
| on: | |
| push: | |
| branches: [main, dev] | |
| pull_request: | |
| branches: [main, dev] | |
| workflow_dispatch: | |
| jobs: | |
| ci: | |
| name: Run tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| 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 | |
| run: | | |
| pytest | |
| deploy: | |
| name: Deploy to Hugging Face Space | |
| needs: ci # ✅ Lance le CD seulement si les tests passent | |
| if: github.ref == 'refs/heads/main' # ✅ Ne déploie que si on est sur main | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Push to Hugging Face Space | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| git remote add space https://Tbruand:$HF_TOKEN@huggingface.co/spaces/Ymokay/ToxiCheck || true | |
| git push space main --force |