Sync from Supabase #26
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 from Supabase | |
| on: | |
| # Run daily at 2 AM UTC | |
| schedule: | |
| - cron: "0 2 * * *" | |
| # Allow manual trigger | |
| workflow_dispatch: | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Sync from Supabase | |
| env: | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }} | |
| run: node scripts/sync-from-supabase.mjs | |
| - name: Generate README | |
| run: node scripts/generate-readme.mjs | |
| - name: Commit and push changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add db/resources.json db/categories.json README.md | |
| # Only commit if there are changes | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "chore: sync from Supabase ($(date -u +%Y-%m-%d))" | |
| git push | |
| fi | |
| - name: Create summary | |
| run: | | |
| echo "## Sync from Supabase Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ -f db/resources.json ]; then | |
| API_COUNT=$(jq '.count' db/resources.json) | |
| echo "**APIs synced:** $API_COUNT" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| if [ -f db/categories.json ]; then | |
| CAT_COUNT=$(jq '.count' db/categories.json) | |
| echo "**Categories synced:** $CAT_COUNT" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Date:** $(date -u +%Y-%m-%d\ %H:%M:%S\ UTC)" >> $GITHUB_STEP_SUMMARY |