kohlin commited on
Commit
b9cea0f
·
1 Parent(s): d71a1fa

Update hf-deploy.yml

Browse files
Files changed (1) hide show
  1. .github/workflows/hf-deploy.yml +41 -34
.github/workflows/hf-deploy.yml CHANGED
@@ -6,39 +6,46 @@ on:
6
  - main
7
 
8
  jobs:
9
- deploy-to-hf-space:
10
  runs-on: ubuntu-latest
 
11
  steps:
12
- - name: Checkout Repository
13
- uses: actions/checkout@v3
14
-
15
- - name: Configure Git
16
- run: |
17
- git config --global user.name "GitHub Actions"
18
- git config --global user.email "actions@github.com"
19
-
20
- - name: Setup .netrc for Hugging Face Authentication
21
- env:
22
- HF_TOKEN: ${{ secrets.HF_TOKEN }}
23
- run: |
24
- echo "machine huggingface.co login ${HF_TOKEN} password x" > ~/.netrc
25
- chmod 600 ~/.netrc
26
-
27
- - name: Clone Hugging Face Space Repository
28
- env:
29
- HF_REPO: kohlin/nlp-spacy # Replace with your Hugging Face Space repository name.
30
- run: |
31
- git clone https://huggingface.co/${HF_REPO}.git space-repo
32
-
33
- - name: Copy Files to Hugging Face Space Repo
34
- run: |
35
- rsync -av --exclude='.git' ./ space-repo/
36
-
37
- - name: Commit and Push Changes to Hugging Face Space
38
- env:
39
- HF_REPO: kohlin/nlp-spacy
40
- run: |
41
- cd space-repo
42
- git add .
43
- git commit -m "Deploy updated app from GitHub Actions" || echo "No changes to commit"
44
- git push https://huggingface.co/${HF_REPO}.git
 
 
 
 
 
 
 
6
  - main
7
 
8
  jobs:
9
+ deploy:
10
  runs-on: ubuntu-latest
11
+
12
  steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v3
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v3
20
+ with:
21
+ python-version: 3.9
22
+
23
+ - name: Install Hugging Face CLI
24
+ run: |
25
+ pip install huggingface_hub
26
+ mkdir -p ~/.huggingface
27
+ echo ${{ secrets.HF_TOKEN }} > ~/.huggingface/token
28
+ huggingface-cli login --token ${{ secrets.HF_TOKEN }}
29
+
30
+ - name: Configure Git for Hugging Face
31
+ run: |
32
+ git config --global user.name "nkofficial-1005"
33
+ git config --global user.email "nikita.datascience@gmail.com"
34
+ # Set the remote to your Hugging Face Space repo (update the repo name if needed)
35
+ git remote add hf https://huggingface.co/spaces/kohlin/nlp-spacy || true
36
+ git remote set-url hf https://kohlin:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/kohlin/nlp-spacy
37
+
38
+ - name: Set up Git LFS (if needed)
39
+ run: |
40
+ git lfs install
41
+ git lfs pull hf main || true
42
+
43
+ - name: Pull latest changes from Hugging Face (merge histories)
44
+ run: |
45
+ git pull hf main --allow-unrelated-histories --no-rebase || true
46
+
47
+ - name: Push latest code to Hugging Face
48
+ run: |
49
+ git push hf main --force-with-lease
50
+ env:
51
+ HUGGINGFACE_TOKEN: ${{ secrets.HF_TOKEN }}