Spaces:
Sleeping
Sleeping
Development Process: dev repo & staging HF Space
This repo contains the recommended steps and scripts to create a safe development workflow by using a separate dev GitHub repository and a Hugging Face Space called my-webapp-hf-dev.
Why use separate dev repo & staging HF space?
- Isolates LLM-driven changes and auto-modify actions from
main(the canonical repository). - Allows automated testing and human review before merging into
main. - Lets you safely assign tokens and access to a staging HF space.
Recommended flow
- Create a dev GitHub repository (e.g.,
NLarchive/my-webapp-hf-dev). - Use
scripts/clone-to-dev.shorscripts/clone-to-dev.ps1to copy code and push to the dev repo and to the HF spacemy-webapp-hf-dev. - Add GitHub Secrets to the dev repo (HF_TOKEN, GEMINI_API_KEY, GITHUB_TOKEN or GitHub App credentials). Do not add them to the canonical repo unless required.
- Change dev repo
.github/workflows/sync-to-hf.ymlto use.hf-config-devinstead of.hf-configif you prefer. - Enable
ENABLE_AUTO_MODIFY=trueon the dev repo for iterative improvements; require PR review before merging tomain. - Add branch protection rules to the
mainrepo requiring tests and approvals.
Scripts
scripts/clone-to-dev.sh: Bash script to create a GitHub repo (usesgh), create.hf-config-dev, and optionally push to Hugging Face Space dev.scripts/clone-to-dev.ps1: PowerShell equivalent.
Example: Create dev repo with CLI
Bash usage:
# Use GitHub CLI to create dev repo and push
./scripts/clone-to-dev.sh -r NLarchive/my-webapp-hf-dev -s my-webapp-hf-dev -u NLarchive
PowerShell usage:
pwsh -File .\scripts\clone-to-dev.ps1 -GHRepo "NLarchive/my-webapp-hf-dev" -HFSpace "my-webapp-hf-dev" -HFUser "NLarchive"
Env/Secrets to store in dev repo
HF_TOKEN(Hugging Face write token)GEMINI_API_KEY(if using Gemini in dev)GITHUB_TOKENorGH_APP_*credentials for GitHub AppENABLE_AUTO_MODIFY=truefor dev if you want to experiment
Good practices
- Always create PRs from dev into main, never push auto-modifications directly to
main. - Use
CODEOWNERSto protect critical code paths. - Keep
ENABLE_AUTO_MODIFY=falseinmain. - Add end-to-end acceptance tests and GitHub Actions checks for PRs.
If you want I can also:
- Add a
sync-to-hf-dev.ymlworkflow for the dev repo. - Update
scripts/clone-to-dev.shto pass additional flags and create aCODEOWNERSautomatically. - Add a helper to copy GH Actions templates with
sync-to-hf.ymlupdated to.hf-config-dev.
What do you want next?