rriviere's picture
ci: add dev branch trigger and separate prod/dev deploy jobs
dc0b0c3
Raw History Blame Contribute Delete
1.62 kB
name: CI/CD
on:
push:
branches:
- main
- dev
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout du code
uses: actions/checkout@v4
- name: Configuration Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Installation des dépendances
run: pip install -r requirements.txt
- name: Exécution des tests
run: pytest tests/ -v
deploy-prod:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout du code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Déploiement sur Hugging Face (prod)
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git config user.email "action@github.com"
git config user.name "GitHub Actions"
git remote add hf https://rriviere:$HF_TOKEN@huggingface.co/spaces/${{ vars.HF_SPACE_PROD }}
git push hf main --force
deploy-dev:
needs: test
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
steps:
- name: Checkout du code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Déploiement sur Hugging Face (dev)
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git config user.email "action@github.com"
git config user.name "GitHub Actions"
git remote add hf https://rriviere:$HF_TOKEN@huggingface.co/spaces/${{ vars.HF_SPACE_DEV }}
git push hf HEAD:main --force