Spaces:
Running
Running
创建 deploy-hf-space.yml
Browse files
.github/workflows/deploy-hf-space.yml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Deploy to Hugging Face Space
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- main
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
deploy:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- name: Checkout
|
| 14 |
+
uses: actions/checkout@v4
|
| 15 |
+
with:
|
| 16 |
+
fetch-depth: 0
|
| 17 |
+
|
| 18 |
+
- name: Validate required secrets
|
| 19 |
+
env:
|
| 20 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 21 |
+
HF_SPACE_ID: ${{ secrets.HF_SPACE_ID }}
|
| 22 |
+
run: |
|
| 23 |
+
test -n "$HF_TOKEN" || (echo "Missing secret HF_TOKEN" && exit 1)
|
| 24 |
+
test -n "$HF_SPACE_ID" || (echo "Missing secret HF_SPACE_ID" && exit 1)
|
| 25 |
+
|
| 26 |
+
- name: Push repository to Hugging Face Space
|
| 27 |
+
env:
|
| 28 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 29 |
+
HF_SPACE_ID: ${{ secrets.HF_SPACE_ID }}
|
| 30 |
+
run: |
|
| 31 |
+
git config --global user.name "github-actions[bot]"
|
| 32 |
+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 33 |
+
git remote add hf "https://oauth2:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE_ID}"
|
| 34 |
+
git push hf HEAD:main --force
|