Spaces:
Sleeping
Sleeping
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 "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Install huggingface_hub | |
run: pip install huggingface_hub | |
- name: Login to Hugging Face (store token as a secret) | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
run: | | |
echo $HF_TOKEN | huggingface-cli login | |
- name: Get Space Name | |
id: get_space_name | |
run: echo ${{ matrix.space_name }} | |
- name: Add Hugging Face Space as remote (loop through each space) | |
run: | | |
git remote add ${{ steps.get_space_name.outputs.value }} https://$david-oplatka/$${{ steps.get_space_name.outputs.value }}.git | |
git config --add remote.$ ${{ steps.get_space_name.outputs.value }}.oauth_token ${{ secrets.HF_TOKEN }} | |
- name: Get changed files | |
id: changed_files | |
run: | | |
git diff --name-only origin/main HEAD | |
- name: Push only changed files (loop through each space) | |
run: | | |
git push ${{ steps.get_space_name.outputs.value }} --prune $(echo ${{ steps.changed_files.outputs.value }}) | |