Spaces:
Sleeping
Sleeping
dani-ange
commited on
Update train-deploy.yaml
Browse files
.github/workflows/train-deploy.yaml
CHANGED
@@ -15,28 +15,17 @@ jobs:
|
|
15 |
- name: Checkout repository
|
16 |
uses: actions/checkout@v3
|
17 |
with:
|
18 |
-
fetch-depth: 0 # Fetch all branches
|
19 |
|
20 |
-
- name: Set up Git
|
21 |
run: |
|
22 |
git config --global user.email "[email protected]"
|
23 |
git config --global user.name "dani-ange"
|
24 |
|
25 |
-
- name:
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
- name: Merge PR changes into master
|
31 |
-
run: |
|
32 |
-
# Ensure the PR branch is properly merged
|
33 |
-
if git branch -r | grep "origin/${{ github.head_ref }}"; then
|
34 |
-
git merge --no-ff origin/${{ github.head_ref }} -m "Merging PR changes from ${{ github.head_ref }}"
|
35 |
-
git push origin master # Push merged changes
|
36 |
-
else
|
37 |
-
echo "Error: Branch ${{ github.head_ref }} does not exist in remote."
|
38 |
-
exit 1
|
39 |
-
fi
|
40 |
|
41 |
- name: Install dependencies
|
42 |
run: pip install -r requirements.txt
|
@@ -48,16 +37,36 @@ jobs:
|
|
48 |
run: |
|
49 |
huggingface-cli login --token "${{ secrets.HUGGINGFACE_API_TOKEN }}" --add-to-git-credential
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
- name: Deploy to Hugging Face
|
52 |
env:
|
53 |
HF_TOKEN: ${{ secrets.HUGGINGFACE_API_TOKEN }}
|
54 |
run: |
|
55 |
huggingface-cli login --token $HF_TOKEN
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
else
|
60 |
-
git add .
|
61 |
git commit -m "Updated model after merging PR"
|
62 |
-
git push https://danielle2003:[email protected]/spaces/danielle2003/diabeties-ml
|
|
|
|
|
63 |
fi
|
|
|
15 |
- name: Checkout repository
|
16 |
uses: actions/checkout@v3
|
17 |
with:
|
18 |
+
fetch-depth: 0 # Fetch full history and all branches
|
19 |
|
20 |
+
- name: Set up Git identity
|
21 |
run: |
|
22 |
git config --global user.email "[email protected]"
|
23 |
git config --global user.name "dani-ange"
|
24 |
|
25 |
+
- name: Set up Python
|
26 |
+
uses: actions/setup-python@v3
|
27 |
+
with:
|
28 |
+
python-version: 3.8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
- name: Install dependencies
|
31 |
run: pip install -r requirements.txt
|
|
|
37 |
run: |
|
38 |
huggingface-cli login --token "${{ secrets.HUGGINGFACE_API_TOKEN }}" --add-to-git-credential
|
39 |
|
40 |
+
- name: Fetch all branches
|
41 |
+
run: |
|
42 |
+
git fetch --all # Ensure we have all branch updates
|
43 |
+
|
44 |
+
- name: Merge main into master
|
45 |
+
run: |
|
46 |
+
git checkout master # Switch to master branch
|
47 |
+
git pull origin master # Get the latest master
|
48 |
+
|
49 |
+
git checkout main
|
50 |
+
git pull origin main # Ensure main is up to date
|
51 |
+
|
52 |
+
git checkout master
|
53 |
+
if git merge --no-ff main -m "Merging changes from main into master"; then
|
54 |
+
echo "Merge successful."
|
55 |
+
git push origin master
|
56 |
+
else
|
57 |
+
echo "No changes to merge or merge conflict detected."
|
58 |
+
fi
|
59 |
+
|
60 |
- name: Deploy to Hugging Face
|
61 |
env:
|
62 |
HF_TOKEN: ${{ secrets.HUGGINGFACE_API_TOKEN }}
|
63 |
run: |
|
64 |
huggingface-cli login --token $HF_TOKEN
|
65 |
|
66 |
+
git add .
|
67 |
+
if ! git diff --cached --exit-code; then
|
|
|
|
|
68 |
git commit -m "Updated model after merging PR"
|
69 |
+
git push https://danielle2003:[email protected]/spaces/danielle2003/diabeties-ml main
|
70 |
+
else
|
71 |
+
echo "No changes to commit."
|
72 |
fi
|