name: Deploy to Hugging Face Spaces # To enable this workflow: # 1. Create a Hugging Face account and create a Space at https://hf.co/new-space # 2. Get your HF token from https://hf.co/settings/tokens (with write access) # 3. Add HF_TOKEN as a repository secret in GitHub Settings > Secrets and variables > Actions # 4. Update the environment variables below with your HF username, space name, and token name on: workflow_run: workflows: ["CI"] types: - completed branches: [ main ] workflow_dispatch: env: HF_USERNAME: "thompsonson" HF_SPACE_NAME: "bayesian_game" HF_TOKEN_NAME: "bayesian_game" jobs: deploy: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 lfs: true - name: Push to Hugging Face Spaces env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | if [ -z "$HF_TOKEN" ]; then echo "Error: HF_TOKEN secret not set. Please add your Hugging Face token to repository secrets." exit 1 fi git config --global user.email "action@github.com" git config --global user.name "GitHub Action" git remote add hf https://${{ env.HF_TOKEN_NAME }}:$HF_TOKEN@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} git push hf main --force