Add hf-deploy.yml
Browse files
.github/workflows/hf-deploy.yml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Deploy to Hugging Face Spaces
|
2 |
+
|
3 |
+
# Trigger this workflow on pushes to the main branch.
|
4 |
+
on:
|
5 |
+
push:
|
6 |
+
branches:
|
7 |
+
- main
|
8 |
+
|
9 |
+
jobs:
|
10 |
+
deploy-to-hf-space:
|
11 |
+
runs-on: ubuntu-latest
|
12 |
+
steps:
|
13 |
+
- name: Checkout Repository
|
14 |
+
uses: actions/checkout@v3
|
15 |
+
|
16 |
+
- name: Configure Git
|
17 |
+
run: |
|
18 |
+
git config --global user.name "GitHub Actions"
|
19 |
+
git config --global user.email "[email protected]"
|
20 |
+
|
21 |
+
- name: Clone Hugging Face Space Repository
|
22 |
+
env:
|
23 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
24 |
+
HF_REPO: kohlin/nlp-spacy # <-- Replace with your Hugging Face Space repo name.
|
25 |
+
run: |
|
26 |
+
# Clone the HF space repo into a folder named "space-repo"
|
27 |
+
git clone https://[email protected]/${HF_REPO} space-repo
|
28 |
+
|
29 |
+
- name: Copy Files to Hugging Face Space Repo
|
30 |
+
run: |
|
31 |
+
# Copy all files from the current repo into the space repo folder (excluding .git)
|
32 |
+
rsync -av --exclude='.git' ./ space-repo/
|
33 |
+
|
34 |
+
- name: Commit and Push Changes to Hugging Face Space
|
35 |
+
env:
|
36 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
37 |
+
HF_REPO: kohlin/nlp-spacy
|
38 |
+
run: |
|
39 |
+
cd space-repo
|
40 |
+
git add .
|
41 |
+
git commit -m "Deploy updated app from GitHub Actions" || echo "No changes to commit"
|
42 |
+
git push https://[email protected]/${HF_REPO}.git
|