name: Update Space on: push: branches: - main jobs: sync-to-hub: runs-on: ubuntu-latest strategy: matrix: space_name: [company-pet-policy, about-mls, shakespeare] # List your Hugging Face space names here steps: - name: Checkout repository uses: actions/checkout@v2 with: fetch-depth: 0 lfs: true - name: Configure Git run: | git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" - name: Install huggingface_hub run: pip install huggingface_hub - name: Login to Hugging Face (use secret token) env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | huggingface-cli login --token $HF_TOKEN - name: Get changed files id: changed_files run: | git fetch origin git diff --name-only HEAD~1 HEAD - name: Push only changed files (loop through each space) run: | changed_files=$(echo "${{ steps.changed_files.outputs.value }}") for file in $changed_files; do git add $file git commit -m "Updating $file" git remote add ${{ matrix.space_name }} https://huggingface.co/spaces/david-oplatka/${{ matrix.space_name }}.git git config --add remote.${{ matrix.space_name }}.oauth_token ${{ secrets.HF_TOKEN }} git push ${{ matrix.space_name }} main done