Files

76 lines
3.1 KiB
YAML

name: build-worker
# Cloud build for the Saw chamber serverless worker — no local docker needed.
# Builds live/Dockerfile.worker (deps baked: numpy<2, transformers 4.51.3,
# torch 2.4 cu121, runpod) and pushes to ghcr. After the first run, make the
# package public (github.com/users/terrafying/packages) so RunPod can pull
# it anonymously, then point the serverless template at the image.
on:
push:
branches: [master]
paths: ["live/Dockerfile.worker", "live/worker.py", "live/server.py",
"live/requirements.txt", "live/jlens_l18_qwen3-4b.pt",
".github/workflows/build-worker.yml"]
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./live
file: ./live/Dockerfile.worker
push: true
tags: |
ghcr.io/terrafying/saw-chamber-worker:v4
ghcr.io/terrafying/saw-chamber-worker:latest
ghcr.io/terrafying/saw-chamber-worker:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Roll out: repoint the endpoint's template at the immutable :sha tag we
# just pushed. Warm workers keep the old image until their idle timeout
# recycles them — that lag is expected, not a failed rollout.
- name: Roll out to RunPod endpoint
env:
RUNPOD_API_KEY: ${{ secrets.RUNPOD_API_KEY }}
TEMPLATE_ID: zim816iihe # saw-chamber-v4 endpoint czgfu4ls4nhyp6
IMAGE: ghcr.io/terrafying/saw-chamber-worker:${{ github.sha }}
run: |
if [ -z "$RUNPOD_API_KEY" ]; then echo "no RUNPOD_API_KEY secret - skipping rollout"; exit 0; fi
code=$(curl -s -o /tmp/rollout.json -w "%{http_code}" -m 60 -X PATCH \
-H "User-Agent: Mozilla/5.0" -H "Content-Type: application/json" \
-H "Authorization: Bearer $RUNPOD_API_KEY" \
"https://rest.runpod.io/v1/templates/$TEMPLATE_ID" \
-d "{\"imageName\": \"$IMAGE\"}")
echo "template PATCH HTTP $code"
python3 -c "import json; print('template now pins:', json.load(open('/tmp/rollout.json')).get('imageName'))" \
|| cat /tmp/rollout.json
[ "$code" = "200" ] || { echo "rollout FAILED"; exit 1; }
# RunPod pulls anonymously, so the package must be public. Code in the
# image is already public via the site tarballs — no new exposure.
- name: Make package public
run: |
curl -sS -o /dev/null -w "%{http_code}\n" -X PATCH \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/user/packages/container/saw-chamber-worker \
-d '{"package_type":"container","visibility":"public"}' || true