name: Deploy to Hugging Face Space on: push: branches: - main workflow_dispatch: jobs: deploy-to-space: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Push to Hugging Face Space env: # GitHub Secretsに設定したHF_TOKENを利用 HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | # Hugging Face Spaceのリポジトリをクローン git clone https://chibafes-dev-admin:$HF_TOKEN@huggingface.co/spaces/chibafes-dev/circle-search-26-api space-repo # .gitディレクトリとクローン先ディレクトリを除き、全ファイルをコピー # これにより、Actions内で生成したデータファイルもSpaceに同期 rsync -av --delete --exclude='.git/' --exclude='space-repo/' ./ space-repo/ # Spaceリポジトリ内で変更をコミットし、プッシュ cd space-repo git config user.name "GitHub Actions" git config user.email "actions@github.com" git add . # 変更がある場合のみコミットを実行 if ! git diff-index --quiet HEAD; then git commit -m "Update from GitHub Actions" fi # chibafes-dev-admin の部分はトークンを発行した Hugging Face のユーザー名 git push https://chibafes-dev-admin:$HF_TOKEN@huggingface.co/spaces/chibafes-dev/circle-search-26-api main