name: Sync to Hugging Face hub on: push: branches: [main] workflow_dispatch: env: HF_TOKEN: ${{ secrets.HF_TOKEN }} HF_USERNAME: "alvaroalon2" SPACE_NAME: "LinguAIcoach" jobs: sync-to-hub: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 lfs: true - name: Check large files uses: ppremk/lfs-warning@v3.3 with: filesizelimit: 10MB # so we can sync to HF Spaces - name: config git run: | git config --global user.name "${{ github.actor }}" git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" git config pull.rebase true - name: Pull from hub run: git pull https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME - name: Push to hub run: git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main - name: Install Poetry uses: snok/install-poetry@v1 - name: Generate requirements.txt from poetry run: poetry export --without-hashes -f requirements.txt --output requeriments.txt - name: Generate pre-requirements.txt run: echo "pip>=24.0" > pre-requirements.txt - name: Add HF model card run: cat model_card.md | cat - README.md > temp && mv temp README.md - name: Update HF README run: | git add README.md requeriments.txt pre-requirements.txt git commit -m "Update HF README adding model card, added requirements.txt and pre-requirements.txt" git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME