litellm/.github/workflows/monitor_databricks_pricing.yml
leecoder 56d7dff551 ci(workflow): accept repository_dispatch and let manual triggers run on the fork
- repository_dispatch (event_type: dbx-monitor) provides an external
  trigger for price-drift alerting to kick off a check
- the job guard previously allowed only workflow_dispatch on the fork,
  which would have skipped repository_dispatch runs; now only the
  schedule event is pinned to upstream so cron never races, while both
  manual trigger types run on either repo
2026-09-08 15:34:22 +09:00

88 lines
3.7 KiB
YAML

name: Monitor Databricks Pricing
# Daily monitor of the Databricks Foundation Model Serving pricing pages.
# Before PR #38950 merges this workflow only lives on the leecoder/litellm
# fork (manual dispatch); after the merge it runs on BerriAI/litellm's cron.
# PRs are always created in the repository the workflow runs in, so the
# built-in GITHUB_TOKEN is sufficient - no PAT or secret required.
on:
schedule:
- cron: "0 2 * * *" # daily 02:00 UTC
workflow_dispatch:
# external trigger: POST /repos/<owner>/<repo>/dispatches {"event_type":"dbx-monitor"}
repository_dispatch:
types: [dbx-monitor]
permissions:
contents: write
pull-requests: write
env:
UPSTREAM_REPO: BerriAI/litellm
UPSTREAM_BASE: litellm_internal_staging
# branch that carries the monitor script until PR #38950 lands upstream
SCRIPT_REF: feat/dbx-pricing-monitor-clean
jobs:
monitor-db-pricing:
# the merged cron fires on both repos; upstream owns the schedule so the
# two never race on the same base. manual triggers run on either repo.
if: github.event_name != 'schedule' || github.repository == 'BerriAI/litellm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: false
fetch-depth: 0
repository: ${{ env.UPSTREAM_REPO }}
ref: ${{ env.UPSTREAM_BASE }}
- name: Bootstrap monitor script until #38950 lands upstream
run: |
if [ ! -f scripts/monitor_databricks_pricing.py ]; then
mkdir -p scripts
curl -fsSL "https://raw.githubusercontent.com/leecoder/litellm/${SCRIPT_REF}/scripts/monitor_databricks_pricing.py" \
-o scripts/monitor_databricks_pricing.py
fi
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: "3.12"
- name: Run monitor
id: monitor
shell: bash
run: |
set -o pipefail
python scripts/monitor_databricks_pricing.py | tee /tmp/monitor_out.txt
if grep -q '^NO_CHANGE' /tmp/monitor_out.txt; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Open PR if changed
if: steps.monitor.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
GITHUB_TOKEN_FOR_PUSH: ${{ github.token }}
run: |
BRANCH="monitor-dbx-pricing-$(date +'%Y-%m-%d')"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json
git commit -m "chore(model_prices): refresh Databricks Foundation Model Serving rates - automated monitor detected changed DBU rates on the Databricks pricing pages; refreshed the mapped databricks/* entries."
git push "https://x-access-token:${GITHUB_TOKEN_FOR_PUSH}@github.com/${GITHUB_REPOSITORY}.git" "HEAD:refs/heads/$BRANCH"
{
cat /tmp/dbx_monitor_pr_body.md
echo
echo "---"
echo "Auto-generated by the Databricks pricing monitor. \`PROMO_SKIPPED\`/\`REVIEW\`/\`MISSING_FROM_PAGE\` lines need human attention; \`UPDATED\` lines were applied automatically."
} > /tmp/dbx_pr_body_final.md
gh pr create --repo "$GITHUB_REPOSITORY" \
--base "$UPSTREAM_BASE" \
--head "$BRANCH" \
--title "chore(model_prices): refresh Databricks Foundation Model Serving rates" \
--body-file /tmp/dbx_pr_body_final.md