1- name : Deploy main to Hugging Face Space (SDSC/ai-agent)
1+ name : Deploy to Hugging Face Space
22
33on :
44 push :
5- branches : [ main ]
5+ branches :
6+ - main
67 workflow_dispatch :
78
89jobs :
@@ -13,23 +14,17 @@ jobs:
1314 - name : Checkout code
1415 uses : actions/checkout@v4
1516 with :
16- fetch-depth : 0
17- lfs : true
17+ fetch-depth : 1
18+ lfs : false
1819
19- # Remove assets so they are not pushed to HF
20- - name : Remove assets folder for HF push
20+ - name : Prepare clean HF deploy branch without assets
2121 run : |
22- rm -rf assets
23- git rm -r --cached assets || true
22+ git config user.email "ci@github.actions"
23+ git config user.name "github-actions[bot]"
2424
25- # 👇 This step ONLY changes README in the CI workspace, not in your repo
26- - name : Generate Hugging Face README with YAML frontmatter
27- run : |
28- # Keep original README content
29- mv README.md README.project.md
25+ original_readme="$(cat README.md)"
3026
31- # Create new README with HF config at the top
32- cat << 'EOF' > README.md
27+ cat > README.md <<EOF
3328 ---
3429 title: AI Agent
3530 emoji: 🤖
@@ -40,22 +35,20 @@ jobs:
4035 pinned: false
4136 ---
4237
38+ $original_readme
4339 EOF
4440
45- # Append the original README content below the YAML block
46- cat README.project.md >> README.md
41+ rm -rf assets
4742
48- # Commit this *locally* so we can push it to the HF remote
49- git config user.email "ci@github.actions"
50- git config user.name "github-actions[bot]"
51- git add README.md
52- git commit -m "Add HF Spaces frontmatter to README for deployment" || echo "No changes to commit"
43+ git checkout --orphan hf-deploy
44+
45+ git add -A
46+ git commit -m "Deploy to Hugging Face Space"
5347
54- - name : Push main to HF Space SDSC/ai-agent
48+ - name : Push to HF Space
5549 env :
5650 HF_TOKEN : ${{ secrets.HF_TOKEN }}
5751 run : |
58- # Push the current branch (main, with the local README commit) to the Space's main
5952 git push --force \
6053 https://SDSC:${HF_TOKEN}@huggingface.co/spaces/SDSC/ai-agent \
61- HEAD :main
54+ hf-deploy :main
0 commit comments