Sync Supabase Data #188
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: Sync Supabase Data | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Runs daily at midnight UTC | |
| workflow_dispatch: # Allows for manual trigger | |
| jobs: | |
| sync-data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Clear npm cache | |
| run: npm cache clean --force | |
| - name: Install dependencies | |
| run: npm install axios @supabase/supabase-js | |
| - name: Fetch data from Supabase | |
| env: | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | |
| run: | | |
| node scripts/fetch_data.js | |
| # Conditionally commit and push if data changed | |
| - name: Commit and push changes | |
| if: env.DATA_CHANGED == 'true' | |
| env: | |
| ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }} | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add public-data/*.json | |
| git commit -m "Update data" | |
| git push origin main |