Daily Data Update #473
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: Daily Data Update | |
| on: | |
| schedule: | |
| # Run daily at midnight UTC | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: # Allow manual trigger for testing | |
| jobs: | |
| update-data: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install openai python-dotenv | |
| - name: Download latest Foundry Models pricing data | |
| run: | | |
| python meter-download.py --foundry-models-only --ndjson prices.ndjson | |
| - name: Download latest GitHub pricing data | |
| run: | | |
| python meter-download.py --github --ndjson prices-github.ndjson | |
| - name: Split price file into monthly files | |
| run: | | |
| python split_into_monthly.py | |
| - name: Generate AI summaries | |
| run: | | |
| python create-ai-summaries.py | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} | |
| AZURE_OPENAI_V1_API_ENDPOINT: ${{ secrets.AZURE_OPENAI_V1_API_ENDPOINT }} | |
| AZURE_OPENAI_API_MODEL: ${{ secrets.AZURE_OPENAI_API_MODEL }} | |
| - name: Generate markdown index | |
| run: | | |
| python monthly/generate-index.py array | |
| - name: Generate RSS feed | |
| run: | | |
| python generate-rss.py | |
| - name: Update metadata timestamp | |
| run: | | |
| python -c " | |
| import json | |
| from datetime import datetime, timezone | |
| # Update last_updated timestamp | |
| current_time = datetime.now(timezone.utc) | |
| formatted_time = current_time.strftime('%d %B %Y %H:%M UTC') | |
| metadata = { | |
| 'last_updated': formatted_time | |
| } | |
| # Save metadata | |
| with open('metadata.json', 'w') as f: | |
| json.dump(metadata, f, indent=2) | |
| " | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add prices.ndjson prices-github.ndjson metadata.json monthly/ agent/rss.xml | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| echo "changes_made=false" >> $GITHUB_OUTPUT | |
| else | |
| git commit -m "Daily data update: $(date -u +'%Y-%m-%d %H:%M UTC')" | |
| git push | |
| echo "changes_made=true" >> $GITHUB_OUTPUT | |
| fi | |
| id: commit_step | |
| - name: Trigger deployment | |
| if: steps.commit_step.outputs.changes_made == 'true' | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| event-type: data-updated |