Team Ai
Apppublic

delqhi/code-devops

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
deploy-huggingface-space.yml52 linesDownload Raw Back to workflows
1name: Deploy Hugging Face Space2 3on:4  workflow_dispatch:5  push:6    branches: [main]7 8jobs:9  deploy:10    if: ${{ secrets.HF_TOKEN != '' }}11    runs-on: ubuntu-latest12    env:13      HF_TOKEN: ${{ secrets.HF_TOKEN }}14      HF_SPACE_REPO_ID: delqhi/sin-code-devops15    steps:16      - name: Checkout17        uses: actions/checkout@v418 19      - name: Setup Python20        uses: actions/setup-python@v521        with:22          python-version: '3.11'23 24      - name: Install deployment dependencies25        run: pip install huggingface_hub26 27      - name: Create or ensure Hugging Face Space28        run: |29          python - <<'PY'30          import os31          from huggingface_hub import HfApi32 33          repo_id = os.environ["HF_SPACE_REPO_ID"].strip()34          if not repo_id:35              raise SystemExit("HF_SPACE_REPO_ID missing")36 37          api = HfApi(token=os.environ["HF_TOKEN"])38          api.create_repo(repo_id=repo_id, repo_type="space", space_sdk="docker", exist_ok=True)39          PY40 41      - name: Push repository contents to Hugging Face Space42        run: |43          set -euo pipefail44          git config --global user.name "GitHub Actions"45          git config --global user.email "actions@github.com"46          git clone "https://oauth2:${HF_TOKEN}@huggingface.co/spaces/delqhi/sin-code-devops" hf-space47          rsync -a --delete             --exclude ".git/"             --exclude ".github/"             --exclude "node_modules/"             --exclude "dist/"             ./ hf-space/48          cd hf-space49          git add .50          git commit -m "Deploy SIN-Code-DevOps from GitHub Actions" || true51          git push origin main52