fix(ci): only run certain workflows on main litellm repo

This commit is contained in:
wagnerjt 2025-03-31 18:01:35 -07:00
parent 46b3dbde8f
commit df82d8a950
2 changed files with 17 additions and 15 deletions

View file

@ -2,11 +2,12 @@ name: Updates model_prices_and_context_window.json and Create Pull Request
on: on:
schedule: schedule:
- cron: "0 0 * * 0" # Run every Sundays at midnight - cron: "0 0 * * 0" # Run every Sundays at midnight
#- cron: "0 0 * * *" # Run daily at midnight #- cron: "0 0 * * *" # Run daily at midnight
jobs: jobs:
auto_update_price_and_context_window: auto_update_price_and_context_window:
if: github.repository == 'BerriAI/litellm' && github.event_name == 'schedule'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -25,4 +26,4 @@ jobs:
--head auto-update-price-and-context-window-$(date +'%Y-%m-%d') \ --head auto-update-price-and-context-window-$(date +'%Y-%m-%d') \
--base main --base main
env: env:
GH_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }}

View file

@ -7,12 +7,13 @@ permissions:
on: on:
push: push:
paths: paths:
- 'schema.prisma' # Check root schema.prisma - "schema.prisma" # Check root schema.prisma
branches: branches:
- main - main
jobs: jobs:
publish-migrations: publish-migrations:
if: github.repository == 'BerriAI/litellm' && github.event_name == 'push'
runs-on: ubuntu-latest runs-on: ubuntu-latest
services: services:
postgres: postgres:
@ -28,7 +29,7 @@ jobs:
--health-interval 10s --health-interval 10s
--health-timeout 5s --health-timeout 5s
--health-retries 5 --health-retries 5
# Add shadow database service # Add shadow database service
postgres_shadow: postgres_shadow:
image: postgres:14 image: postgres:14
@ -50,7 +51,7 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: '3.x' python-version: "3.x"
- name: Install Dependencies - name: Install Dependencies
run: | run: |
@ -65,7 +66,7 @@ jobs:
run: | run: |
mkdir -p deploy/migrations mkdir -p deploy/migrations
echo 'provider = "postgresql"' > deploy/migrations/migration_lock.toml echo 'provider = "postgresql"' > deploy/migrations/migration_lock.toml
if [ -z "$(ls -A deploy/migrations/2* 2>/dev/null)" ]; then if [ -z "$(ls -A deploy/migrations/2* 2>/dev/null)" ]; then
echo "No existing migrations found, creating baseline..." echo "No existing migrations found, creating baseline..."
VERSION=$(date +%Y%m%d%H%M%S) VERSION=$(date +%Y%m%d%H%M%S)
@ -119,19 +120,19 @@ jobs:
run: | run: |
# Create temporary migration workspace # Create temporary migration workspace
mkdir -p temp_migrations mkdir -p temp_migrations
# Copy existing migrations (will not fail if directory is empty) # Copy existing migrations (will not fail if directory is empty)
cp -r deploy/migrations/* temp_migrations/ 2>/dev/null || true cp -r deploy/migrations/* temp_migrations/ 2>/dev/null || true
VERSION=$(date +%Y%m%d%H%M%S) VERSION=$(date +%Y%m%d%H%M%S)
# Generate diff against existing migrations or empty state # Generate diff against existing migrations or empty state
prisma migrate diff \ prisma migrate diff \
--from-migrations temp_migrations \ --from-migrations temp_migrations \
--to-schema-datamodel schema.prisma \ --to-schema-datamodel schema.prisma \
--shadow-database-url "${SHADOW_DATABASE_URL}" \ --shadow-database-url "${SHADOW_DATABASE_URL}" \
--script > temp_migrations/migration_${VERSION}.sql --script > temp_migrations/migration_${VERSION}.sql
# Check if there are actual changes # Check if there are actual changes
if [ -s temp_migrations/migration_${VERSION}.sql ]; then if [ -s temp_migrations/migration_${VERSION}.sql ]; then
echo "Changes detected, creating new migration" echo "Changes detected, creating new migration"
@ -152,7 +153,7 @@ jobs:
run: | run: |
# Create test database # Create test database
psql "${SHADOW_DATABASE_URL}" -c 'CREATE DATABASE migration_test;' psql "${SHADOW_DATABASE_URL}" -c 'CREATE DATABASE migration_test;'
# Apply all migrations in order to verify # Apply all migrations in order to verify
for migration in deploy/migrations/*/migration.sql; do for migration in deploy/migrations/*/migration.sql; do
echo "Applying migration: $migration" echo "Applying migration: $migration"
@ -166,7 +167,7 @@ jobs:
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/BerriAI/litellm/collaborators https://api.github.com/repos/BerriAI/litellm/collaborators
echo "\nChecking if token can create PRs..." echo "\nChecking if token can create PRs..."
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
@ -177,7 +178,7 @@ jobs:
run: | run: |
echo "Files staged for commit:" echo "Files staged for commit:"
git diff --name-status --staged git diff --name-status --staged
echo "\nAll changed files:" echo "\nAll changed files:"
git status git status
@ -190,7 +191,7 @@ jobs:
title: "Update Prisma Migrations" title: "Update Prisma Migrations"
body: | body: |
Auto-generated migration based on schema.prisma changes. Auto-generated migration based on schema.prisma changes.
Generated files: Generated files:
- deploy/migrations/${VERSION}_schema_update/migration.sql - deploy/migrations/${VERSION}_schema_update/migration.sql
- deploy/migrations/${VERSION}_schema_update/README.md - deploy/migrations/${VERSION}_schema_update/README.md
@ -203,4 +204,4 @@ jobs:
# Only add migration files # Only add migration files
git add deploy/migrations/ git add deploy/migrations/
git status # Debug what's being committed git status # Debug what's being committed
git commit -m "chore: update prisma migrations" git commit -m "chore: update prisma migrations"