3v324v23's picture
Auto deploy from GitHub Actions
8d9926c
name: SentinelNet CI
on:
push:
branches: ["main"]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Check Python syntax
run: |
python -m py_compile app.py
- name: Test Flask app startup
run: |
export SKIP_MODEL=true
python app.py &
for i in {1..10}; do
if curl -fsS http://127.0.0.1:7860/health; then
echo "Server is up!"
exit 0
fi
echo "Waiting for server..."
sleep 2
done
echo "Server failed to start"
exit 1
- name: Build Docker image
run: |
docker build -t sentinelnet .
# 🚀 CD STEP (correct placement)
- name: Deploy to HuggingFace Spaces
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
pip install huggingface_hub
sudo apt-get update
sudo apt-get install -y rsync
git config --global user.email "you@example.com"
git config --global user.name "github-actions"
git clone https://Hitan2004:$HF_TOKEN@huggingface.co/spaces/Hitan2004/sentinelnet hf_space
rsync -av --exclude='.git' ./ hf_space/
cd hf_space
git add .
git commit -m "Auto deploy from GitHub Actions" || echo "No changes to commit"
git push