Spaces:
Sleeping
Sleeping
ci: add dev branch trigger and separate prod/dev deploy jobs
Browse files- Trigger CI/CD on push to `dev` branch in addition to `main`
- Rename `deploy` job to `deploy-prod`, conditioned on `refs/heads/main`
- Add `deploy-dev` job targeting `HF_SPACE_DEV` variable, conditioned on `refs/heads/dev`
- Use `vars.HF_SPACE_PROD` variable instead of hardcoded HF space name
- .github/workflows/ci_cd.yml +24 -3
.github/workflows/ci_cd.yml
CHANGED
|
@@ -4,6 +4,7 @@ on:
|
|
| 4 |
push:
|
| 5 |
branches:
|
| 6 |
- main
|
|
|
|
| 7 |
|
| 8 |
jobs:
|
| 9 |
test:
|
|
@@ -23,8 +24,9 @@ jobs:
|
|
| 23 |
- name: Exécution des tests
|
| 24 |
run: pytest tests/ -v
|
| 25 |
|
| 26 |
-
deploy:
|
| 27 |
needs: test
|
|
|
|
| 28 |
runs-on: ubuntu-latest
|
| 29 |
steps:
|
| 30 |
- name: Checkout du code
|
|
@@ -32,11 +34,30 @@ jobs:
|
|
| 32 |
with:
|
| 33 |
fetch-depth: 0
|
| 34 |
|
| 35 |
-
- name: Déploiement sur Hugging Face
|
| 36 |
env:
|
| 37 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 38 |
run: |
|
| 39 |
git config user.email "action@github.com"
|
| 40 |
git config user.name "GitHub Actions"
|
| 41 |
-
git remote add hf https://rriviere:$HF_TOKEN@huggingface.co/spaces/
|
| 42 |
git push hf main --force
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
push:
|
| 5 |
branches:
|
| 6 |
- main
|
| 7 |
+
- dev
|
| 8 |
|
| 9 |
jobs:
|
| 10 |
test:
|
|
|
|
| 24 |
- name: Exécution des tests
|
| 25 |
run: pytest tests/ -v
|
| 26 |
|
| 27 |
+
deploy-prod:
|
| 28 |
needs: test
|
| 29 |
+
if: github.ref == 'refs/heads/main'
|
| 30 |
runs-on: ubuntu-latest
|
| 31 |
steps:
|
| 32 |
- name: Checkout du code
|
|
|
|
| 34 |
with:
|
| 35 |
fetch-depth: 0
|
| 36 |
|
| 37 |
+
- name: Déploiement sur Hugging Face (prod)
|
| 38 |
env:
|
| 39 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 40 |
run: |
|
| 41 |
git config user.email "action@github.com"
|
| 42 |
git config user.name "GitHub Actions"
|
| 43 |
+
git remote add hf https://rriviere:$HF_TOKEN@huggingface.co/spaces/${{ vars.HF_SPACE_PROD }}
|
| 44 |
git push hf main --force
|
| 45 |
+
|
| 46 |
+
deploy-dev:
|
| 47 |
+
needs: test
|
| 48 |
+
if: github.ref == 'refs/heads/dev'
|
| 49 |
+
runs-on: ubuntu-latest
|
| 50 |
+
steps:
|
| 51 |
+
- name: Checkout du code
|
| 52 |
+
uses: actions/checkout@v4
|
| 53 |
+
with:
|
| 54 |
+
fetch-depth: 0
|
| 55 |
+
|
| 56 |
+
- name: Déploiement sur Hugging Face (dev)
|
| 57 |
+
env:
|
| 58 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 59 |
+
run: |
|
| 60 |
+
git config user.email "action@github.com"
|
| 61 |
+
git config user.name "GitHub Actions"
|
| 62 |
+
git remote add hf https://rriviere:$HF_TOKEN@huggingface.co/spaces/${{ vars.HF_SPACE_DEV }}
|
| 63 |
+
git push hf HEAD:main --force
|