Initial release: GemYum - On-device AI Nutrition Tracking #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy Nutrition Database | |
| on: | |
| push: | |
| paths: | |
| - 'scripts/build_comprehensive_nutrients_db.py' | |
| - '.github/workflows/build-nutrition-database.yml' | |
| workflow_dispatch: | |
| inputs: | |
| force_rebuild: | |
| description: 'Force rebuild even if no changes' | |
| required: false | |
| default: false | |
| type: boolean | |
| jobs: | |
| build-database: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests | |
| - name: Build nutrition database | |
| run: | | |
| cd scripts | |
| python build_comprehensive_nutrients_db.py --output-dir ../build/databases | |
| - name: Upload database artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: nutrition-databases | |
| path: | | |
| build/databases/*.db | |
| build/databases/*.db.gz | |
| build/databases/*.json | |
| retention-days: 30 | |
| - name: Calculate checksums | |
| run: | | |
| cd build/databases | |
| sha256sum *.db *.db.gz > checksums.txt | |
| cat checksums.txt | |
| # Deploy to your CDN/hosting service | |
| # Example using AWS S3: | |
| - name: Configure AWS credentials | |
| if: github.ref == 'refs/heads/main' | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Deploy to S3 | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| aws s3 sync build/databases/ s3://your-bucket/gemmunch/ \ | |
| --exclude "*" \ | |
| --include "*.db.gz" \ | |
| --include "*.json" \ | |
| --include "checksums.txt" \ | |
| --cache-control "max-age=86400" | |
| # Alternative: Deploy to GitHub Releases | |
| - name: Create Release | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: db-v${{ github.run_number }} | |
| release_name: Nutrition Database v${{ github.run_number }} | |
| body: | | |
| Automated nutrition database build. | |
| ## Files | |
| - `nutrients.db.gz` - Full database (compressed) | |
| - `nutrients_lite.db.gz` - Lite database (compressed) | |
| - `nutrients_manifest.json` - Version manifest | |
| - `checksums.txt` - SHA256 checksums | |
| draft: false | |
| prerelease: false | |
| - name: Upload Release Assets | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./build/databases/nutrients.db.gz | |
| asset_name: nutrients.db.gz | |
| asset_content_type: application/gzip |