Abhinav Gavireddi
[fix]: Fixed code issues
c613bb1
name: CI & Deploy
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv
uv pip install --system -r requirements.txt
# - name: Run tests
# run: |
# if [ -f tests/test.py ]; then python -m unittest discover -s tests; fi
deploy-to-hf:
runs-on: ubuntu-latest
needs: build-and-test
environment: prod
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # full history if you need versioning
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Hugging Face Hub client
run: pip install huggingface_hub
- name: Configure Git credential helper
run: |
# Use the "store" helper so huggingface-cli can write credentials here
git config --global credential.helper store
- name: Push to Hugging Face Space
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_USERNAME: ${{ secrets.HF_USERNAME }}
HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
run: |
echo "πŸš€ Pushing code to HF Space..."
# Configure Git identity
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Login and add the token to Git credential store
huggingface-cli login --token "$HF_TOKEN" --add-to-git-credential
# Add HF Space repo as remote and push
git remote add hf https://huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}.git
git fetch hf main
git push hf main --force
# Optional: Restart Space via API
python -c "from huggingface_hub import HfApi; api = HfApi(token='$HF_TOKEN'); api.restart_space(repo_id='${HF_USERNAME}/${HF_SPACE_NAME}')"