cfahlgren1's picture
cfahlgren1 HF staff
add contribution guide
f3219d4
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 # Fetch all history for all branches and tags
- 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."