RyZ
deploy: deploy to HF
3f4cccf
name: Deploy to Huggingface
on:
push:
branches:
- main
jobs:
deploy-to-huggingface:
runs-on: ubuntu-latest
steps:
# Checkout repository
- name: Checkout Repository
uses: actions/checkout@v3
# Setup Git
- name: Setup Git for Huggingface
run: |
git config --global user.email "everyrelativity@gmail.com"
git config --global user.name "Ryu2804"
# Clone Huggingface Space Repository
- name: Clone Huggingface Space
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git clone https://huggingface.co/spaces/XRyZ/${{secrets.HF_REPO_NAME}} space
# Update Git Remote URL and Pull Latest Changes
- name: Update Remote and Pull Changes
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
cd space
git remote set-url origin https://XRyZ:$HF_TOKEN@huggingface.co/spaces/XRyZ/${{secrets.HF_REPO_NAME}}
git pull origin main || echo "No changes to pull"
# Clean Space Directory - Delete all files except .git
- name: Clean Space Directory
run: |
cd space
find . -mindepth 1 -not -path "./.git*" -delete
# Copy Files to Huggingface Space
- name: Copy Files to Space
run: |
rsync -av --exclude='.git' ./ space/
# Commit and Push to Huggingface Space
- name: Commit and Push to Huggingface
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
cd space
git add .
git commit -m "Deploy files from GitHub repository" || echo "No changes to commit"
git push origin main || echo "No changes to push"