Spaces:
Sleeping
Sleeping
| name: Sync PR to Hugging Face Dev Space | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - ready_for_review | |
| jobs: | |
| sync-to-hf-dev: | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| env: | |
| HF_SPACE_ID: S-Dreamer/ThtratLandscapeChat-dev | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install HF Hub | |
| run: | | |
| pip install --upgrade pip | |
| pip install huggingface_hub | |
| - name: Sync to HF | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| GITHUB_REF_NAME: ${{ github.ref_name }} | |
| GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| python - << 'EOF' | |
| import os | |
| from huggingface_hub import upload_folder, HfApi | |
| token = os.getenv("HF_TOKEN") | |
| repo_id = os.getenv("HF_SPACE_ID") | |
| api = HfApi() | |
| api.whoami(token) | |
| upload_folder( | |
| repo_id=repo_id, | |
| repo_type="space", | |
| folder_path=".", | |
| token=token, | |
| commit_message=f"Sync PR #{os.getenv('GITHUB_PR_NUMBER')} ({os.getenv('GITHUB_REF_NAME')})" | |
| ) | |
| EOF |