Spaces:
Build error
Build error
nitinrawatisMLeng
fix(docker): use npm install instead of npm ci to fix cross-platform lock file issue
6bb6663 | name: CI / Deploy to Hugging Face Spaces | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| # ββ 1. Build check β runs on every push and every PR ββββββββββββββββββββββ | |
| # | |
| # Catches compilation and build errors before anything is deployed. | |
| # Both Go and the React frontend must build cleanly to pass. | |
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| build-check: | |
| name: Build check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # ββ Go backend ββ | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.23" | |
| cache-dependency-path: Apps/licensemanagerApp/backend/go.sum | |
| - name: Build Go backend | |
| working-directory: Apps/licensemanagerApp/backend | |
| run: go build ./... | |
| # ββ React frontend ββ | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: npm | |
| cache-dependency-path: Apps/licensemanagerApp/frontend/package-lock.json | |
| - name: Install frontend dependencies | |
| working-directory: Apps/licensemanagerApp/frontend | |
| run: npm install | |
| - name: Build frontend | |
| working-directory: Apps/licensemanagerApp/frontend | |
| run: npm run build | |
| # ββ 2. Deploy β only on push to main, only after build-check passes ββββββββ | |
| # | |
| # Pushes this repository to the Hugging Face Space's git remote. | |
| # HF Spaces detects the push, builds the Dockerfile, and redeploys. | |
| # | |
| # Required GitHub Secrets (Settings β Secrets β Actions): | |
| # HF_TOKEN β Hugging Face access token (write access) | |
| # | |
| # Required GitHub Variables (Settings β Variables β Actions): | |
| # HF_USERNAME β your Hugging Face username e.g. "futurealgos" | |
| # HF_SPACE_NAME β the Space name e.g. "licensemanager" | |
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| deploy: | |
| name: Deploy to HF Spaces | |
| runs-on: ubuntu-latest | |
| needs: build-check | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout (full history) | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # full history so the push is not a shallow clone | |
| - name: Push to Hugging Face Spaces | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| HF_USERNAME: ${{ vars.HF_USERNAME }} | |
| HF_SPACE_NAME: ${{ vars.HF_SPACE_NAME }} | |
| run: | | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| # Add the HF Space as a remote (token embedded in URL for auth) | |
| git remote add hf-space \ | |
| https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} | |
| # Force-push so HF Space always matches the GitHub main branch exactly | |
| git push hf-space HEAD:main --force | |