name: Sync to Hugging Face hub on: push: branches: [main] workflow_dispatch: jobs: sync-to-hub: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 lfs: true - name: Push to HuggingFace env: HF_TOKEN: ${{ secrets.HF_TOKEN }} HF_USERNAME: ${{ vars.HF_USERNAME || 'Ma-Ri-Ba-Ku' }} HF_SPACE: ${{ vars.HF_SPACE || 'Ma-Ri-Ba-Ku/Picarones' }} run: | git remote add hf "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE}" || true # HuggingFace renvoie régulièrement des 500/503 transitoires sur # ses miroirs Git. On retry 5 fois avec backoff linéaire # (15s, 30s, 45s, 60s) — total max ~2,5 min, suffisant pour # absorber un incident court côté HF. attempts=5 for i in $(seq 1 $attempts); do if git push --force hf main; then echo "Push HuggingFace réussi (tentative $i/$attempts)" exit 0 fi if [ "$i" -lt "$attempts" ]; then delay=$((15 * i)) echo "Tentative $i/$attempts échouée — nouvelle tentative dans ${delay}s..." sleep $delay fi done echo "::error::Push HuggingFace échoué après $attempts tentatives (incident HF probable, réessayer plus tard via workflow_dispatch)" >&2 exit 1