update-models #35
Workflow file for this run
This file contains 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-models | |
on: | |
workflow_dispatch: | |
inputs: | |
staging: | |
description: 'push to staging registry' | |
required: false | |
default: false | |
type: boolean | |
permissions: | |
contents: write | |
packages: write | |
id-token: write | |
jobs: | |
update-models: | |
strategy: | |
fail-fast: false | |
matrix: | |
model: | |
# TODO: remove this before merge | |
# - llama-2-7b-chat | |
# - llama-2-7b-chat-cuda | |
# - llama-2-13b-chat | |
# - llama-2-13b-chat-cuda | |
# - orca-2-13b | |
# - orca-2-13b-cuda | |
# - phi-2-2.7b | |
# - phi-2-2.7b-cuda | |
- llama-3-8b-instruct | |
- llama-3-8b-instruct-cuda | |
# due to github runner disk space limitations, these do not fit in to runners | |
# - mixtral-7x8b-instruct | |
# - mixtral-7x8b-instruct-cuda | |
runs-on: ubuntu-latest | |
timeout-minutes: 360 | |
steps: | |
- uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 | |
with: | |
tool-cache: true | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Harden Runner | |
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 | |
with: | |
egress-policy: block | |
allowed-endpoints: > | |
auth.docker.io:443 | |
*.huggingface.co:443 | |
fulcio.sigstore.dev:443 | |
gcr.io:443 | |
ghcr.io:443 | |
github.com:443 | |
huggingface.co:443 | |
*.githubusercontent.com:443 | |
production.cloudflare.docker.com:443 | |
registry-1.docker.io:443 | |
rekor.sigstore.dev:443 | |
storage.googleapis.com:443 | |
tuf-repo-cdn.sigstore.dev:443 | |
sertaccdn.azureedge.net:443 | |
developer.download.nvidia.com:443 | |
deb.debian.org:80 | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- name: Install Cosign | |
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | |
- uses: crazy-max/ghaction-github-runtime@b3a9207c0e1ef41f4cf215303c976869d0c2c1c4 # v3.0.0 | |
- name: Login to GHCR | |
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: parse matrix | |
run: | | |
echo "MODEL_NAME=$(echo ${{ matrix.model }} | sed -E 's/([a-z]+)-([0-9]+x[0-9]+b)-.*/\1/' | sed -E 's/([a-z]+)-([0-9]+)-.*/\1\2/')" >> $GITHUB_ENV | |
echo "MODEL_SIZE=$(echo ${{ matrix.model }} | sed -E 's/[a-z]+-([0-9]+x[0-9]+b|[0-9]+\.?[0-9]*b)-.*/\1/' | sed -E 's/[a-z]+-[0-9]+-([0-9]+\.?[0-9]*b).*/\1/')" >> $GITHUB_ENV | |
echo "MODEL_TYPE=-$(echo ${{ matrix.model }} | sed -n -e 's/.*\(chat\).*/\1/p' -e 's/.*\(instruct\).*/\1/p')" >> $GITHUB_ENV | |
echo "MODEL_RUNTIME=-$(echo ${{ matrix.model }} | grep -Eo 'cuda')" >> $GITHUB_ENV | |
- name: Build and push | |
run: | | |
# since empty output includes a dash, we remove it completely if it's only a dash | |
if [ "${MODEL_RUNTIME}" == "-" ]; then | |
export MODEL_RUNTIME="" | |
echo "MODEL_RUNTIME=''" >> $GITHUB_ENV | |
fi | |
if [ "${MODEL_TYPE}" == "-" ]; then | |
export MODEL_TYPE="" | |
echo "MODEL_TYPE=''" >> $GITHUB_ENV | |
fi | |
if ${{ inputs.staging }}; then | |
export REGISTRY=ghcr.io/sozercan/test | |
else | |
export REGISTRY=ghcr.io/sozercan | |
fi | |
docker buildx build . \ | |
-t ${REGISTRY}/${MODEL_NAME}:${MODEL_SIZE}${MODEL_RUNTIME} \ | |
-t ${REGISTRY}/${MODEL_NAME}:${MODEL_SIZE}${MODEL_TYPE}${MODEL_RUNTIME} \ | |
-f models/${{ matrix.model }}.yaml \ | |
--push --progress plain \ | |
--sbom=true --provenance=true \ | |
--cache-from=type=gha,scope=${MODEL_NAME}-${MODEL_SIZE} \ | |
--cache-to=type=gha,scope=${MODEL_NAME}-${MODEL_SIZE},mode=max | |
echo "DIGEST=$(cosign triangulate ${REGISTRY}/${MODEL_NAME}:${MODEL_SIZE}${MODEL_RUNTIME} --type digest)" >> $GITHUB_ENV | |
- name: Sign the images with GitHub OIDC Token | |
if: ${{ !inputs.staging }} | |
run: cosign sign --yes ${DIGEST} | |
- name: Verify image signature | |
if: ${{ !inputs.staging }} | |
run: | | |
cosign verify ${DIGEST} \ | |
--certificate-oidc-issuer https://token.actions.githubusercontent.com \ | |
--certificate-identity https://github.com/sozercan/aikit/.github/workflows/update-models.yaml@refs/heads/main |