Spaces:
Sleeping
Sleeping
name: Train and Deploy Model | |
on: | |
pull_request: | |
branches: | |
- master # Runs when a PR is made to master | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
train-evaluate-deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch full history and all branches | |
- name: Set up Git identity | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "dani-ange" | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Upgrade Hugging Face Hub | |
run: pip install --upgrade huggingface_hub | |
- name: Authenticate with Hugging Face | |
run: | | |
huggingface-cli login --token "${{ secrets.HUGGINGFACE_API_TOKEN }}" --add-to-git-credential | |
- name: Fetch all branches | |
run: | | |
git fetch --all # Ensure we have all branch updates | |
- name: Merge main into master | |
run: | | |
git checkout master # Switch to master branch | |
git pull origin master # Get the latest master | |
git checkout main | |
git pull origin main # Ensure main is up to date | |
#git checkout master | |
#if git merge --no-ff main -m "Merging changes from main into master"; then | |
#echo "Merge successful." | |
#git push origin master | |
#else | |
#echo "No changes to merge or merge conflict detected." | |
#fi | |
- name: Deploy to Hugging Face | |
env: | |
HF_TOKEN: ${{ secrets.HUGGINGFACE_API_TOKEN }} | |
run: | | |
huggingface-cli login --token $HF_TOKEN | |
# Set merge strategy to rebase | |
git config pull.rebase true | |
# Ensure local repository is up-to-date before pushing | |
git push --force https://danielle2003:[email protected]/spaces/danielle2003/diabeties main | |