Spaces:
Sleeping
Sleeping
name: Deploy to Hugging Face | |
on: | |
push: | |
branches: | |
- main | |
- master | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
lfs: true | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Config git | |
run: | | |
git config --global credential.helper store | |
git config --global user.email "actions@github.com" | |
git config --global user.name "github-actions" | |
- name: Configure Hugging Face | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
HF_USERNAME: ${{ secrets.HF_USERNAME }} | |
run: | | |
# Install Hugging Face CLI | |
pip install huggingface-hub | |
# Login to Hugging Face | |
huggingface-cli login --token $HF_TOKEN --add-to-git-credential | |
- name: Push to Hugging Face | |
env: | |
HF_USERNAME: ${{ secrets.HF_USERNAME }} | |
SPACE_NAME: ${{ secrets.SPACE_NAME }} | |
run: | | |
# Create repository URL | |
REPO_URL="https://huggingface.co/spaces/$HF_USERNAME/template-python" | |
# Add Hugging Face as a remote and push | |
git remote add space $REPO_URL || git remote set-url space $REPO_URL | |
git push -f space main |