name: Sync to Hugging Face Spaces on: push: branches: - main workflow_dispatch: jobs: sync: runs-on: ubuntu-latest steps: - name: Checkout GitHub Repository uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.10" - name: Install Hugging Face Hub CLI run: | python -m pip install --upgrade pip pip install huggingface_hub - name: Clone Hugging Face Spaces Repository run: | huggingface-cli login --token $HF_TOKEN --add-to-git-credential git clone https://huggingface.co/spaces/adaptsum/demo hf_space cd hf_space git checkout main env: HF_TOKEN: ${{ secrets.HUGGINGFACE_TOKEN }} - name: Copy Files to Hugging Face Repo run: | rsync -av --exclude='requirements.txt' --exclude='.git' --exclude='README.md' --exclude='hf_space' ./ hf_space/ - name: Merge README.md Files run: | cat hf_space/README.md README.md > hf_space/README_combined.md mv hf_space/README_combined.md hf_space/README.md rm -rf hf_space/README_combined.md - name: Commit and Push Changes run: | cd hf_space git add . if git diff --cached --quiet; then echo "No changes to commit" else huggingface-cli upload adaptsum/demo . . --repo-type=space echo "Changes have been pushed." fi env: HUGGINGFACE_TOKEN: ${{ secrets.HUGGINGFACE_TOKEN }}