Skip to content

build

build #6

Workflow file for this run

name: build
on:
schedule:
- cron: "23 5 * * *" # daily: pick up new upstream stable releases
push:
branches: [main]
paths:
- Dockerfile
- patch/**
- .github/workflows/build.yml
workflow_dispatch:
inputs:
litellm_version:
description: "LiteLLM release tag (e.g. v1.93.0). Empty = latest stable release."
required: false
permissions:
contents: read
packages: write
actions: read # notify job reads previous run conclusions
concurrency:
group: build
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
strategy:
fail-fast: false
matrix:
include:
# plain image: consumed by litellm-lagoon (Lagoon/docker-compose)
- upstream: litellm
package: litellm-lagoon-base
# -database image: consumed by the litellm helm chart (k0rdent)
- upstream: litellm-database
package: litellm-lagoon-base-database
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/${{ matrix.package }}
steps:
- uses: actions/checkout@v4
- name: Resolve LiteLLM version
id: version
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION='${{ inputs.litellm_version }}'
if [ -z "$VERSION" ]; then
VERSION="$(gh api repos/BerriAI/litellm/releases --jq '[.[] | select(.prerelease | not)][0].tag_name')"
fi
[ -n "$VERSION" ] || { echo "could not resolve a LiteLLM version"; exit 1; }
echo "version=$VERSION" | tee -a "$GITHUB_OUTPUT"
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# On scheduled runs, skip versions we already published. Pushes to
# main (patch/Dockerfile changes) always republish the current version.
- name: Check if already published
id: published
if: github.event_name == 'schedule'
run: |
if docker manifest inspect "$IMAGE:${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" | tee -a "$GITHUB_OUTPUT"
fi
- uses: docker/setup-qemu-action@v3
if: steps.published.outputs.exists != 'true'
- uses: docker/setup-buildx-action@v3
if: steps.published.outputs.exists != 'true'
- uses: docker/build-push-action@v6
if: steps.published.outputs.exists != 'true'
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
LITELLM_IMAGE=ghcr.io/berriai/${{ matrix.upstream }}
LITELLM_VERSION=${{ steps.version.outputs.version }}
tags: |
${{ env.IMAGE }}:${{ steps.version.outputs.version }}
${{ env.IMAGE }}:latest
# One Slack message per breakage, not per matrix leg or per scheduled
# retry: skip posting when the previous completed run also failed.
notify:
runs-on: ubuntu-latest
needs: build
if: failure()
steps:
- name: Check previous run conclusion
id: prev
env:
GH_TOKEN: ${{ github.token }}
run: |
PREV="$(gh api "repos/${{ github.repository }}/actions/workflows/build.yml/runs?status=completed&per_page=1" --jq '.workflow_runs[0].conclusion')"
echo "conclusion=$PREV" | tee -a "$GITHUB_OUTPUT"
- name: Post to Slack
if: steps.prev.outputs.conclusion != 'failure'
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ vars.SLACK_CHANNEL_ID }}
TEXT: ":rotating_light: litellm-lagoon-base build failed for LiteLLM ${{ needs.build.outputs.version || 'unknown' }} — the patch may no longer apply. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
run: |
curl -fsS -X POST https://slack.com/api/chat.postMessage \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H 'Content-type: application/json; charset=utf-8' \
--data "$(jq -n --arg c "$SLACK_CHANNEL_ID" --arg t "$TEXT" '{channel:$c,text:$t}')" \
| jq -e '.ok'