Spaces:
Sleeping
Sleeping
| name: SONIX-ML Continuous Training | |
| on: | |
| # Triggered via Supabase Webhook (Database Changes) | |
| repository_dispatch: | |
| types: [shoe_data_changed] | |
| # Allows manual triggering from GitHub Actions tab (for testing) | |
| workflow_dispatch: | |
| jobs: | |
| train-and-deploy: | |
| runs-on: ubuntu-latest | |
| # Standard permissions (overridden by GH_PAT for the push) | |
| permissions: | |
| contents: write | |
| steps: | |
| # 1. Checkout Code with PERSONAL ACCESS TOKEN | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GH_PAT }} | |
| fetch-depth: 0 # Fetch full history to ensure rebase works | |
| persist-credentials: true # Keep the token for the push step | |
| # 2. Setup Python Environment | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| # 3. Install Dependencies | |
| - name: Install Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| # 4. Execute Training Engine | |
| # This script connects to Supabase, retrains the model, and saves artifacts. | |
| - name: Run Training Pipeline | |
| env: | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | |
| PYTHONPATH: . | |
| run: python -m src.training.training_engine | |
| # 5. Commit, Rebase, and Push | |
| # This step handles version control for the new model artifacts. | |
| - name: Commit and Push New Artifacts | |
| run: | | |
| # Configure Git Identity (Bot) | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "SONIX ML Bot" | |
| # Stage the new model artifacts | |
| git add model_artifacts/ | |
| # Commit changes (if any) | |
| # '|| echo' prevents the workflow from failing if there are no changes | |
| git commit -m "auto: model retraining complete [skip ci]" || echo "No changes to commit" | |
| # PULL REBASE: Critical to prevent 'race conditions' if the repo changed during training | |
| git pull --rebase origin main | |
| # Push changes using the GH_PAT credentials from the checkout step | |
| git push origin main |