Spaces:
Sleeping
Sleeping
| name: Sync and Push to Hugging Face | |
| on: | |
| push: | |
| branches: | |
| - main # Trigger the workflow on push to the main branch | |
| jobs: | |
| sync-and-push: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - space_name: company-pet-policy | |
| space_title: "Vectara Pet Policy" | |
| space_description: "Ask questions about our unique pet policy" | |
| - space_name: about-mls | |
| space_title: "About MLS" | |
| space_description: "Ask questions from the MLS About section" | |
| - space_name: shakespeare | |
| space_title: "Shakespeare and His Plays" | |
| space_description: "Ask some basic questions about Shakespeare and his work" | |
| steps: | |
| - name: Checkout Source Repository | |
| uses: actions/checkout@v2 | |
| - name: Set up SSH for Hugging Face | |
| uses: webfactory/ssh-agent@v0.5.3 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| - name: Configure SSH known hosts for Hugging Face | |
| run: | | |
| mkdir -p ~/.ssh | |
| ssh-keyscan hf.co >> ~/.ssh/known_hosts | |
| - name: Set up Git configuration | |
| run: | | |
| git config --global user.name 'github-actions' | |
| git config --global user.email 'github-actions@github.com' | |
| - name: Clone and Pull Target Hugging Face Repository | |
| run: | | |
| git clone git@hf.co:spaces/david-oplatka/${{ matrix.space_name }}.git $RUNNER_TEMP/spaces/${{ matrix.space_name }} | |
| - name: Sync Source Repository with Temporary Folder | |
| run: | | |
| rsync -av --exclude '.*' $GITHUB_WORKSPACE/ $RUNNER_TEMP/spaces/${{ matrix.space_name }}/ | |
| - name: commit changes | |
| run: | | |
| cd $RUNNER_TEMP/spaces/${{ matrix.space_name }} | |
| sed -i 's/title: "Enter Chatbot Title"/title: ${{ matrix.space_title }}/g' README.md | |
| sed -i 's/short_description: "Enter Description Here"/short_description: ${{ matrix.space_description }}/g' README.md | |
| git add . | |
| git commit -m "Sync updates from source repository" || echo "No changes to commit" | |
| - name: Push changes to Hugging Face Space | |
| env: | |
| HF_ACCESS_TOKEN: ${{ secrets.HF_TOKEN }} # Replace with your actual secret name | |
| run: | | |
| cd $RUNNER_TEMP/spaces/${{ matrix.space_name }} | |
| pwd | |
| git push origin main | |