opencodereview / .github /workflows /deploy-hf.yml
Sdm0's picture
Deploy 07fcb0d7
af62689 verified
Raw History Blame Contribute Delete
1.54 kB
name: Deploy to Hugging Face Spaces
on:
push:
branches: [main]
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install huggingface-hub
run: pip install huggingface-hub
- name: Upload to Hugging Face Space
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
python -c "
import os
from pathlib import Path
from huggingface_hub import HfApi, logging as hf_logging
hf_logging.set_verbosity_info()
api = HfApi(token=os.environ['HF_TOKEN'])
repo_id = 'Sdm0/opencodereview'
print(f'Uploading to {repo_id} ...')
api.upload_folder(
repo_id=repo_id,
repo_type='space',
folder_path=str(Path.cwd()),
path_in_repo='.',
ignore_patterns=[
'*.db', '*.db-wal', '*.db-shm',
'**/__pycache__', '**/*.pyc',
'.env', '.venv',
'.git', '.gitignore', '.github',
],
commit_message=f'Deploy {os.environ.get(\"GITHUB_SHA\", \"?\")[:8]}',
)
print('Upload complete!')
# Explicitly restart to ensure the Space rebuilds
print('Restarting Space...')
api.restart_space(repo_id)
print('Restart triggered!')
"