GitHub Actions · Hugging Face
Hub documentation GitHub Actions Hub API docs Join the Hugging Face community and get access to the augmented documentation experience Collaborate on models, datasets and Spaces Faster examples with accelerated inference Switch between documentation themes to get started GitHub Actions You can use GitHub Actions to automatically sync your GitHub repository to the Hugging Face Hub. The official huggingface/hub-sync action supports syncing Models , Datasets , and Spaces .
For keyless publishing — no HF_TOKEN secret to store or rotate — see Trusted Publishers , which exchanges GitHub Actions’ built-in OIDC token for a short-lived, repo-scoped Hub token at the start of each run. Setup Create a Hugging Face access token with write permission to the target repo. For better security, use a fine-grained token scoped to only the repository you’re syncing to. Add the token as a GitHub secret called HF_TOKEN in your repository settings.
Add a workflow file (e.g. .github/workflows/sync-to-hub.yml ) to your repository. Basic usage name: Sync to Hugging Face Hub on: push: branches: [ main ] jobs: sync: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: huggingface/hub-sync@v0.3.0 with: github_repo_id: ${{ github.repository }} huggingface_repo_id: username/repo-name hf_token: ${{ secrets.HF_TOKEN }} By default, this syncs to a Space . To sync a model or dataset, set the repo_type parameter: - uses: huggingface/hub-sync@v0.3.0 with: github_repo_id: ${{ github.repository }} huggingface_repo_id: username/my-dataset hf_token: ${{ secrets.HF_TOKEN }} repo_type: dataset Parameters Parameter Required Default Description github_repo_id Yes — GitHub repository (use ${{ github.repository }} ) huggingface_repo_id Yes — Target repo on the Hub ( username/repo-name ) hf_token Yes — Hugging Face access token repo_type No space space , model , or dataset space_sdk No gradio gradio , streamlit , docker , or static private No false Whether to create the repo as private subdirectory No .
Sync a specific subdirectory (useful for monorepos) The action mirrors your files to the Hub using the hf CLI — it is not a git-to-git sync. It automatically excludes .github/ and .git/ directories and mirrors deletions (files removed from GitHub will be removed from the Hub). For more complex workflows (e.g. build steps, custom upload logic), you can install and use the hf CLI directly in your workflow instead. For Spaces-specific guidance (file size limits, LFS handling), see Managing Spaces with GitHub Actions .
Update on GitHub ← How-to: Process new files in a bucket with Jobs Notebooks →