reichaves's picture
Update main.yml
e6a166c unverified
name: Sync to Hugging Face hub
on:
push:
branches: [main]
workflow_dispatch:
jobs:
sync-to-hub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
git config pull.rebase false
- name: Initialize if needed
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
if ! git remote | grep -q "hf"; then
git remote add hf https://reichaves:[email protected]/spaces/reichaves/Chatbot-with-MaritacaAI-for-PDFs
fi
- name: Attempt sync
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
# Fetch from Hugging Face
git fetch hf main || true
# Try to merge
if git merge hf/main --allow-unrelated-histories -m "Merge Hugging Face changes" ; then
echo "Merge successful"
else
echo "Merge failed, using local version"
git merge --abort
# Force push local version
git push -f hf main
fi
- name: Push to Hugging Face
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git push hf main || git push -f hf main