|
name: Deploy to Hugging Face Spaces |
|
|
|
on: |
|
push: |
|
branches: |
|
- main |
|
workflow_dispatch: |
|
|
|
jobs: |
|
build-and-deploy: |
|
runs-on: ubuntu-latest |
|
|
|
steps: |
|
- name: Checkout repository |
|
uses: actions/checkout@v3 |
|
with: |
|
fetch-depth: 0 |
|
|
|
- name: Set up Git |
|
run: | |
|
git config user.email "github-actions[bot]@users.noreply.github.com" |
|
git config user.name "github-actions[bot]" |
|
|
|
- name: Add Hugging Face remote |
|
run: | |
|
git remote add hf https://${{ secrets.HF_USERNAME }}:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ secrets.HF_USERNAME }}/${{ secrets.SPACE_NAME }} |
|
|
|
- name: Fetch from Hugging Face |
|
run: | |
|
git fetch hf |
|
|
|
- name: Commit changes if any |
|
run: | |
|
git add . |
|
git diff --cached --quiet || git commit -m "Deploy to Hugging Face Spaces" |
|
|
|
- name: Push to Hugging Face Spaces |
|
run: | |
|
git push hf +main || echo "Failed to deploy." |