umer6016 commited on
Commit
2aeab56
·
verified ·
1 Parent(s): 140d6e6

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. .github/workflows/deploy_to_hf.yml +19 -18
.github/workflows/deploy_to_hf.yml CHANGED
@@ -15,26 +15,27 @@ jobs:
15
  - uses: actions/checkout@v3
16
  with:
17
  fetch-depth: 0
18
- - name: Push to hub
 
 
 
19
  env:
20
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
21
  run: |
22
- # Configure Git
23
- git config --global user.email "action@github.com"
24
- git config --global user.name "GitHub Action"
25
-
26
- # 1. Clone the HF Repo specifically
27
- git clone https://umer6016:$HF_TOKEN@huggingface.co/spaces/umer6016/Stockker hf_space
28
- cd hf_space
29
-
30
- # 2. Delete everything in HF repo (to ensure clean slate) except .git
31
- # (We use find to avoid error if empty)
32
- find . -maxdepth 1 -not -name '.git' -not -name '.' -exec rm -rf {} +
33
 
34
- # 3. Copy files from our GitHub repo (parent dir) to here
35
- cp -r ../* .
36
 
37
- # 4. Add, Commit, Push
38
- git add .
39
- git commit -m "Deploy from GitHub Actions" --allow-empty
40
- git push https://umer6016:$HF_TOKEN@huggingface.co/spaces/umer6016/Stockker main
 
 
 
 
 
 
 
15
  - uses: actions/checkout@v3
16
  with:
17
  fetch-depth: 0
18
+ - name: Install Python dependencies
19
+ run: pip install huggingface_hub
20
+
21
+ - name: Push to Hub (Python Mode)
22
  env:
23
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
24
  run: |
25
+ python -c "
26
+ from huggingface_hub import HfApi
27
+ import os
 
 
 
 
 
 
 
 
28
 
29
+ api = HfApi()
30
+ print('Uploading files to Hugging Face...')
31
 
32
+ # Upload the entire current directory to the Space
33
+ api.upload_folder(
34
+ folder_path='.',
35
+ repo_id='umer6016/Stockker',
36
+ repo_type='space',
37
+ token=os.environ['HF_TOKEN'],
38
+ ignore_patterns=['.git', '.github', '__pycache__', 'vocab.txt']
39
+ )
40
+ print('Upload complete!')
41
+ "