Spaces:
Running
Running
Download .github/workflows/deploy-hf.yml from Sdm0/opencodereview: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/spaces/Sdm0/opencodereview/resolve/main/.github/workflows/deploy-hf.yml
- Command line
-
hf download hf://spaces/Sdm0/opencodereview/.github/workflows/deploy-hf.yml
-
curl -L -o deploy-hf.yml https://huggingface.co/spaces/Sdm0/opencodereview/resolve/main/.github/workflows/deploy-hf.yml
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!') | |
| " | |