cyrille-elie commited on
Commit
8b12c13
·
1 Parent(s): 2a970b7

CD: Added realease.yml for automated Hugging Face Spaces deployment

Browse files
Files changed (1) hide show
  1. .github/workflows/release.yml +57 -0
.github/workflows/release.yml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy to Hugging Face Spaces and Create GitHub Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*' # Se déclenche sur les tags comme v1.0.0, v0.2.1, etc.
7
+
8
+ jobs:
9
+ deploy_and_release:
10
+ name: Deploy to HF Space & Create Release
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: write # Nécessaire pour créer une release GitHub
14
+
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0 # Récupère tout l'historique pour un changelog potentiel
20
+
21
+ - name: Set up Git user for HF push
22
+ run: |
23
+ git config --global user.name "${{ github.actor }}"
24
+ git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
25
+
26
+ - name: Push to Hugging Face Spaces
27
+ env:
28
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
29
+ HF_SPACE_ID: ${{ secrets.HF_SPACE_ID }} # Ex: VotreNomHF/NomDuSpace
30
+ run: |
31
+ echo "Deploying tag ${{ github.ref_name }} to Hugging Face Space: ${HF_SPACE_ID}"
32
+ # Ajoute le remote pour le Space Hugging Face en utilisant le token pour l'authentification
33
+ # La branche sur le Space HF est généralement 'main'
34
+ git remote add space "https://user:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE_ID}"
35
+
36
+ # Pousse le tag actuel vers la branche 'main' du Space HF
37
+ # --force est souvent nécessaire car l'historique du Space peut diverger
38
+ # ou pour s'assurer que la branche main du Space reflète exactement ce tag.
39
+ git push --force space "${{ github.ref_name }}:refs/heads/main"
40
+ echo "Code pushed to Hugging Face Space successfully."
41
+
42
+ - name: Create GitHub Release
43
+ uses: softprops/action-gh-release@v1
44
+ with:
45
+ tag_name: ${{ github.ref_name }}
46
+ name: Release ${{ github.ref_name }}
47
+ body: |
48
+ Release ${{ github.ref_name }} du projet d'attrition RH.
49
+
50
+ **Changements principaux :**
51
+ *(À remplir manuellement lors de la création du tag, ou générer un changelog ici)*
52
+
53
+ Déployé sur Hugging Face Spaces.
54
+ draft: false
55
+ prerelease: false # Mettre à true pour les pré-releases (ex: v1.0.0-beta)
56
+ env:
57
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}