@@ -13,22 +13,15 @@ jobs:
1313 - name : Checkout code
1414 uses : actions/checkout@v4
1515 with :
16- fetch-depth : 0
16+ fetch-depth : 1
1717 lfs : true
1818
19- # Remove assets so they are not pushed to HF
20- - name : Remove assets folder for HF push
19+ - name : Prepare clean HF deploy branch without assets
2120 run : |
22- rm -rf assets
23- git rm -r --cached assets || true
24-
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
21+ # Save original README content
2922 mv README.md README.project.md
3023
31- # Create new README with HF config at the top
24+ # Create Hugging Face README
3225 cat << 'EOF' > README.md
3326 ---
3427 title: AI Agent
@@ -42,20 +35,30 @@ jobs:
4235
4336 EOF
4437
45- # Append the original README content below the YAML block
38+ # Append original README below HF frontmatter
4639 cat README.project.md >> README.md
4740
48- # Commit this *locally* so we can push it to the HF remote
41+ # Remove files/folders that should not be pushed to HF
42+ rm -rf assets
43+
44+ # Create a fresh branch with no previous Git history
45+ git checkout --orphan hf-deploy
46+
47+ # Remove old tracked files from Git index
48+ git rm -rf --cached . || true
49+
50+ # Add current cleaned workspace
51+ git add -A
52+
53+ # Commit cleaned deployment version
4954 git config user.email "ci@github.actions"
5055 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"
56+ git commit -m "Deploy to Hugging Face Space"
5357
54- - name : Push main to HF Space SDSC/ai-agent
58+ - name : Push clean deploy branch to HF Space SDSC/ai-agent
5559 env :
5660 HF_TOKEN : ${{ secrets.HF_TOKEN }}
5761 run : |
58- # Push the current branch (main, with the local README commit) to the Space's main
5962 git push --force \
6063 https://SDSC:${HF_TOKEN}@huggingface.co/spaces/SDSC/ai-agent \
61- HEAD :main
64+ hf-deploy :main
0 commit comments