curatorbot / .github /workflows /deploy-space.yml
ignatius's picture
README as a standard project README; Space configuration moved to a Space card
55cd90c
Raw History Blame Contribute Delete
1.14 kB
name: deploy to Hugging Face Space
# Pushes main to the Space after tests pass.
# Needs repository secret HF_TOKEN (write access) and variable HF_SPACE (e.g. ignatius/curatorbot).
on:
workflow_run:
workflows: [tests]
types: [completed]
branches: [main]
workflow_dispatch:
jobs:
deploy:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0, lfs: true }
- name: Push to Space
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_SPACE: ${{ vars.HF_SPACE }}
run: |
test -n "$HF_TOKEN" && test -n "$HF_SPACE" || { echo "Set HF_TOKEN secret and HF_SPACE variable"; exit 1; }
# The Space reads its configuration from the YAML block of README.md: use the Space card there.
cp space/README.md README.md
git -c user.name="deploy" -c user.email="deploy@users.noreply.github.com" commit -qam "Space card"
git push --force "https://user:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE}" HEAD:main