Update Pricing Data #25
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: Update Pricing Data | |
| on: | |
| schedule: | |
| - cron: '0 2 * * *' # Daily at UTC 02:00 (Beijing 10:00) | |
| workflow_dispatch: | |
| inputs: | |
| mode: | |
| description: 'Scrape mode' | |
| required: false | |
| default: 'default' | |
| type: choice | |
| options: | |
| - default | |
| - llm-only | |
| - no-llm | |
| permissions: | |
| contents: write | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Type check | |
| run: npx tsc --noEmit | |
| - name: Scrape pricing data | |
| env: | |
| # API keys (from secrets) | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| # Custom endpoints: use secret if set, otherwise default | |
| ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL || 'https://api.anthropic.com' }} | |
| ANTHROPIC_MODEL: ${{ secrets.ANTHROPIC_MODEL || 'claude-sonnet-4-5' }} | |
| OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL || '' }} | |
| OPENAI_MODEL: ${{ secrets.OPENAI_MODEL || '' }} | |
| run: | | |
| MODE="${{ github.event.inputs.mode || 'default' }}" | |
| case "$MODE" in | |
| llm-only) npx tsx scripts/index.ts --llm-only ;; | |
| no-llm) npx tsx scripts/index.ts --no-llm ;; | |
| *) npx tsx scripts/index.ts ;; | |
| esac | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet data/; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No pricing changes detected" | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Pricing changes detected:" | |
| git diff --stat data/ | |
| fi | |
| - name: Generate change summary | |
| if: steps.changes.outputs.changed == 'true' | |
| id: summary | |
| run: | | |
| SUMMARY=$(npx tsx scripts/utils/diff-summary.ts 2>/dev/null || echo "Initial data") | |
| echo "summary<<EOF" >> $GITHUB_OUTPUT | |
| echo "$SUMMARY" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Commit and push | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add data/ | |
| git commit -m "chore: update pricing data $(date -u +%Y-%m-%d) | |
| ${{ steps.summary.outputs.summary }}" | |
| git push |