Screenshots #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================= | |
| # Sync to Hugging Face Space (force-by-default) | |
| # ============================================================================= | |
| # Builds a clean deploy tree from deploy/huggingface/ + source code and | |
| # force-pushes to the HuggingFace Space repository. | |
| # | |
| # Required Repository Secrets: | |
| # HF_TOKEN - HuggingFace write token | |
| # HF_USERNAME - HuggingFace username (e.g. ruslanmv) | |
| # SPACE_NAME - HuggingFace Space name (e.g. gitpilot) | |
| # ============================================================================= | |
| name: Sync to Hugging Face Space (force-by-default) | |
| on: | |
| push: | |
| branches: ["main", "master"] | |
| workflow_dispatch: {} | |
| jobs: | |
| sync-to-hub: | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: hf-space-sync-canonical | |
| cancel-in-progress: false | |
| env: | |
| HF_USERNAME: ${{ secrets.HF_USERNAME }} | |
| SPACE_NAME: ${{ secrets.SPACE_NAME }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Build deploy tree and push to HF Space | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| set -e | |
| # -- Validate secrets ------------------------------------------------ | |
| if [ -z "$HF_USERNAME" ] || [ -z "$SPACE_NAME" ]; then | |
| echo "❌ Missing HF_USERNAME or SPACE_NAME repo Secrets." | |
| echo " Add them under: Settings → Secrets and variables → Actions → Secrets." | |
| exit 1 | |
| fi | |
| if [ -z "$HF_TOKEN" ]; then | |
| echo "❌ Missing HF_TOKEN secret (write token for Spaces)." | |
| echo " Add it under: Settings → Secrets and variables → Actions → New repository secret." | |
| exit 1 | |
| fi | |
| REMOTE_URL="https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}" | |
| # -- Build a clean deploy directory with only HF-needed files -------- | |
| DEPLOY_DIR=$(mktemp -d) | |
| echo "📦 Building deploy tree in $DEPLOY_DIR ..." | |
| # HF Space README (with YAML frontmatter) → root | |
| cp deploy/huggingface/README.md "$DEPLOY_DIR/README.md" | |
| # HF Dockerfile → root (replaces repo Dockerfile) | |
| cp deploy/huggingface/Dockerfile "$DEPLOY_DIR/Dockerfile" | |
| # Application source code | |
| cp pyproject.toml "$DEPLOY_DIR/" | |
| cp README.md "$DEPLOY_DIR/REPO_README.md" | |
| cp -r gitpilot "$DEPLOY_DIR/gitpilot" | |
| # Frontend source (needed for multi-stage Docker build) | |
| cp -r frontend "$DEPLOY_DIR/frontend" | |
| # -- Create an orphan commit and force push -------------------------- | |
| cd "$DEPLOY_DIR" | |
| git init -b main | |
| git lfs install --skip-smudge 2>/dev/null || true | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "Deploy from ${GITHUB_SHA::8}" | |
| echo "🔁 Pushing deploy tree → HF Space main..." | |
| git push --force "$REMOTE_URL" main | |
| echo "✅ Sync complete: only Docker deployment files were pushed." |