ALYYAN commited on
Commit
e606cee
·
1 Parent(s): e7e997a

starting deployment

Browse files
Files changed (2) hide show
  1. .github/workflows/main.yaml +64 -0
  2. README.md +3 -1
.github/workflows/main.yaml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # .github/workflows/main.yml
2
+
3
+ name: Deploy App to Hugging Face Spaces
4
+
5
+ on:
6
+ push:
7
+ branches:
8
+ - main # Trigger this workflow on every push to the main branch
9
+
10
+ jobs:
11
+ deploy-to-hub:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ # Step 1: Check out your source code from GitHub
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0 # Fetches all history for Git LFS
20
+
21
+ # Step 2: Set up Python environment
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: '3.11' # Match the Python version you used
26
+
27
+ # Step 3: Install DVC and its Google Drive dependency
28
+ - name: Install DVC
29
+ run: pip install "dvc[gdrive]"
30
+
31
+ # Step 4: Configure DVC with the credentials from GitHub Secrets
32
+ - name: Configure DVC
33
+ env:
34
+ GDRIVE_CREDENTIALS_DATA: ${{ secrets.GDRIVE_CREDENTIALS_DATA }}
35
+ run: |
36
+ mkdir -p .dvc/tmp
37
+ echo "$GDRIVE_CREDENTIALS_DATA" > .dvc/tmp/gdrive-user-credentials.json
38
+
39
+ # Step 5: Pull the large model file from Google Drive
40
+ - name: Pull DVC Artifacts
41
+ run: dvc pull artifacts/model_training/model.dvc -f
42
+
43
+ # Step 6: Log in to Hugging Face Hub
44
+ - name: Log in to Hugging Face Hub
45
+ uses: huggingface/login@v1
46
+ with:
47
+ token: ${{ secrets.HF_TOKEN }}
48
+
49
+ # Step 7: Push the complete app (code + model) to the Space
50
+ - name: Push to HF Space
51
+ env:
52
+ HF_SPACE_TARGET: ${{ secrets.HF_USERNAME }}/${{ secrets.HF_SPACE_NAME }} # Example: ALYYAN/pneumonia-detection-ai
53
+ run: |
54
+ git config --global user.email "action@github.com"
55
+ git config --global user.name "GitHub Action"
56
+ # Clone the Space repo into a new directory
57
+ git clone https://huggingface.co/spaces/${HF_SPACE_TARGET} hf_space_repo
58
+ # Copy all necessary files into the Space repo
59
+ cp -r app/ app.py requirements.txt README.md artifacts/model_training/model/ hf_space_repo/
60
+ cd hf_space_repo
61
+ # Commit and push
62
+ git add .
63
+ git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
64
+ git push
README.md CHANGED
@@ -6,8 +6,10 @@ colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 4.19.1
8
  app_file: app.py
9
- startup_script: setup.sh
10
  pinned: false
 
 
 
11
  ---
12
 
13
  # 🩺 Pneumonia Detection AI
 
6
  sdk: gradio
7
  sdk_version: 4.19.1
8
  app_file: app.py
 
9
  pinned: false
10
+ secrets:
11
+ - MONGODB_CONNECTION_STRING
12
+ # HF_TOKEN is no longer needed here, it's a secret for the runner
13
  ---
14
 
15
  # 🩺 Pneumonia Detection AI