name: Sync to Hugging Face Space (vooom/NewsAnalyze) on: push: branches: - main - master workflow_dispatch: jobs: deploy-huggingface-space: name: Sync Clean Code to Hugging Face Space runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v5 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v5 with: node-version: 22 cache: 'npm' - name: Install, Verify & Build Production Bundle run: | npm ci --no-audit --no-fund npm run lint npm test npm run build - name: Deploy Production App to Hugging Face Space env: HF_TOKEN: ${{ secrets.HF_TOKEN || secrets.HUGGINGFACE_TOKEN || secrets.HUGGING_FACE_HUB_TOKEN }} run: | set -euo pipefail if [ -z "$HF_TOKEN" ]; then echo "::error::HF_TOKEN secret is empty or missing in GitHub Secrets!" echo "Configure repository secret HF_TOKEN (or HUGGINGFACE_TOKEN) with a Hugging Face write token." exit 1 fi # README.md already carries the Space front-matter (sdk: docker, app_port: 7860). head -n 12 README.md | grep -q "^sdk: docker$" || { echo "::error::README.md front-matter must declare sdk: docker"; exit 1; } git config --global user.email "ci@geo-strat.org" git config --global user.name "GeoStrat-CI" # Publish a single orphan commit so the Space never receives binary history. git checkout --orphan hf-deploy-publish git add -A git commit -q -m "Deploy ${GITHUB_SHA::7} to Hugging Face Space [skip ci]" echo "Pushing to Hugging Face Space vooom/NewsAnalyze..." git push --force "https://huggingface:${HF_TOKEN}@huggingface.co/spaces/vooom/NewsAnalyze" hf-deploy-publish:main echo "Hugging Face Space updated; the Space will now build the Docker image."