marintosti12 commited on
Commit
eead467
·
1 Parent(s): b4ab7b8

fix(deploy) : correction de deploy

Browse files
Files changed (1) hide show
  1. .github/workflows/deploy.yaml +21 -10
.github/workflows/deploy.yaml CHANGED
@@ -2,8 +2,8 @@ name: Deploy to Hugging Face
2
 
3
  on:
4
  workflow_run:
5
- workflows: ["CI"]
6
- branches: [ main ]
7
  types: [completed]
8
  workflow_dispatch: {}
9
 
@@ -14,20 +14,31 @@ concurrency:
14
  jobs:
15
  deploy:
16
  runs-on: ubuntu-latest
17
- env:
18
- HF_TOKEN: ${{ secrets.HF_TOKEN || '' }}
19
- HF_SPACE_URL: ${{ secrets.HF_SPACE_URL || '' }}
20
 
21
- # déploie seulement si la CI est "success" ET si les secrets existent
22
- if: ${{ github.event.workflow_run.conclusion == 'success' && env.HF_TOKEN != '' && env.HF_SPACE_URL != '' }}
 
 
 
 
23
 
24
  steps:
25
- - uses: actions/checkout@v4
 
 
 
 
 
 
 
 
26
 
27
  - name: Configure Git
28
  run: |
29
- git config --global user.email "${{ secrets.HF_GIT_EMAIL || 'actions@github.com' }}"
30
- git config --global user.name "${{ secrets.HF_GIT_NAME || 'github-actions' }}"
31
  git lfs install
32
 
33
  - name: Push to Space
 
2
 
3
  on:
4
  workflow_run:
5
+ workflows: ["CI"] # doit correspondre à name: CI dans ton CI
6
+ branches: [ main ] # base branch concernée
7
  types: [completed]
8
  workflow_dispatch: {}
9
 
 
14
  jobs:
15
  deploy:
16
  runs-on: ubuntu-latest
17
+ # ⬇️ NE se lance que si la CI a réussi ET si c'était une CI déclenchée par un PUSH (donc après merge)
18
+ if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }}
 
19
 
20
+ # on expose les secrets en env (utilisables dans les steps)
21
+ env:
22
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
23
+ HF_SPACE_URL: ${{ secrets.HF_SPACE_URL }}
24
+ HF_GIT_EMAIL: ${{ secrets.HF_GIT_EMAIL || 'actions@github.com' }}
25
+ HF_GIT_NAME: ${{ secrets.HF_GIT_NAME || 'github-actions' }}
26
 
27
  steps:
28
+ - name: Checkout
29
+ uses: actions/checkout@v4
30
+
31
+ # garde-fou: si secrets manquants, on sort proprement
32
+ - name: Guard secrets
33
+ if: ${{ !env.HF_TOKEN || !env.HF_SPACE_URL }}
34
+ run: |
35
+ echo "HF secrets manquants, on skip le déploiement."
36
+ exit 0
37
 
38
  - name: Configure Git
39
  run: |
40
+ git config --global user.email "${HF_GIT_EMAIL}"
41
+ git config --global user.name "${HF_GIT_NAME}"
42
  git lfs install
43
 
44
  - name: Push to Space