Deploy Docker Image to Hugging Face Spaces #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Docker Image to Hugging Face Spaces | |
on: | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: pip install --upgrade huggingface_hub | |
- name: Deploy to Hugging Face Spaces | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
SPACE_ID: ${{ secrets.SPACE_ID }} # 替换为你的Space ID,例如 `username/my-space` | |
run: | | |
python -c " | |
from huggingface_hub import HfApi | |
api = HfApi() | |
api.create_repo(repo_id='${{ env.SPACE_ID }}', repo_type='space', token='${{ secrets.HF_TOKEN }}') | |
api.upload_file( | |
path_or_fileobj='Dockerfile', | |
path_in_repo='Dockerfile', | |
repo_id='${{ env.SPACE_ID }}', | |
repo_type='space', | |
token='${{ secrets.HF_TOKEN }}' | |
) | |
" | |
- name: Create and upload Dockerfile | |
run: | | |
echo 'FROM drfyup/rss2tg:latest' > Dockerfile |