CI builds an arm64 image (compositor, host, chandra-remote, modules) and deploys the updater pod that installs it on the phone. chandra-remote updates go in live (SIGUSR2 restarts it in place); the compositor waits for an idle, locked phone or an approval, and a locked session restarts locked. Host tests: the launcher no longer draws its label in a narrow panel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
117 lines
5.6 KiB
YAML
117 lines
5.6 KiB
YAML
# Build the handset image (arm64) and install it on the phone: charts/chandra-handset in nandi/cluster.
|
|
name: Deploy to the handset
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore: ["docs/**", "**.md"]
|
|
workflow_dispatch:
|
|
|
|
# One at a time, the newest waiting: a deploy is never cut off halfway.
|
|
concurrency:
|
|
group: deploy-handset
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Load secrets from the cluster
|
|
env:
|
|
KUBECONFIG_B64: ${{ secrets.KUBECONFIG_B64 }}
|
|
run: |
|
|
set -euo pipefail
|
|
BIN="$RUNNER_TEMP/bin"; mkdir -p "$BIN"
|
|
PKG=https://git.site.latha.org/api/packages/nandi/generic
|
|
fetch() { curl -fsSL --retry 5 --retry-all-errors -o "$2" "$1"; }
|
|
fetch "$PKG/kubectl/v1.37.2/kubectl-linux-amd64" "$BIN/kubectl"
|
|
echo "c04487523e7aa7d1493f7808174c899db93d7a9cf57531420cd76b9bd415f8f4 $BIN/kubectl" | sha256sum -c -
|
|
chmod +x "$BIN/kubectl"
|
|
fetch "$PKG/helm/3.16.3/helm-linux-amd64.tar.gz" "$RUNNER_TEMP/helm.tgz"
|
|
echo "f5355c79190951eed23c5432a3b920e071f4c00a64f75e077de0dd4cb7b294ea $RUNNER_TEMP/helm.tgz" | sha256sum -c -
|
|
tar xzf "$RUNNER_TEMP/helm.tgz" -C "$RUNNER_TEMP" --strip-components=1 linux-amd64/helm
|
|
mv "$RUNNER_TEMP/helm" "$BIN/helm"
|
|
echo "$BIN" >> "$GITHUB_PATH"
|
|
echo "$KUBECONFIG_B64" | base64 -d > "$RUNNER_TEMP/kubeconfig"
|
|
chmod 600 "$RUNNER_TEMP/kubeconfig"
|
|
echo "KUBECONFIG=$RUNNER_TEMP/kubeconfig" >> "$GITHUB_ENV"
|
|
export KUBECONFIG="$RUNNER_TEMP/kubeconfig"
|
|
# Build secrets live in the k8s Secret chandra-handset/chandra-handset-ci (see `latha secret set`).
|
|
for k in DEPOT_TOKEN DEPOT_PROJECT_ID REGISTRY_TOKEN; do
|
|
v="$("$BIN/kubectl" -n chandra-handset get secret chandra-handset-ci -o go-template="{{index .data \"$k\" | base64decode}}")"
|
|
[ -n "$v" ] || { echo "missing $k in secret chandra-handset/chandra-handset-ci"; exit 1; }
|
|
echo "::add-mask::$v"
|
|
printf '%s=%s\n' "$k" "$v" >> "$GITHUB_ENV"
|
|
done
|
|
|
|
- name: Install Depot CLI
|
|
run: |
|
|
curl -fsSL https://depot.dev/install-cli.sh | sh
|
|
echo "$HOME/.depot/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Configure Registry Auth
|
|
env:
|
|
REG_USER: nandi
|
|
run: |
|
|
mkdir -p "$HOME/.docker"
|
|
AUTH=$(printf '%s:%s' "$REG_USER" "$REGISTRY_TOKEN" | base64 -w 0)
|
|
cat > "$HOME/.docker/config.json" <<EOF
|
|
{"auths":{"git.site.latha.org":{"auth":"${AUTH}"}}}
|
|
EOF
|
|
|
|
- name: Build and Push with Depot
|
|
run: |
|
|
SHORT_SHA="${GITHUB_SHA::8}"
|
|
depot build \
|
|
--project "$DEPOT_PROJECT_ID" \
|
|
--platform linux/arm64 \
|
|
--push \
|
|
--file handset/Dockerfile \
|
|
--build-arg RELEASE="${SHORT_SHA}" \
|
|
-t "git.site.latha.org/nandi/chandra-handset:${SHORT_SHA}" \
|
|
-t "git.site.latha.org/nandi/chandra-handset:latest" \
|
|
.
|
|
|
|
- name: Bump chart and deploy with Helm
|
|
env:
|
|
CLUSTER_REPO_TOKEN: ${{ secrets.CLUSTER_REPO_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
SHORT_SHA="${GITHUB_SHA::8}"
|
|
|
|
# Credentials come from a git askpass helper, never the URL or argv.
|
|
printf '#!/bin/sh\necho "$CLUSTER_REPO_TOKEN"\n' > "$RUNNER_TEMP/askpass"
|
|
chmod 700 "$RUNNER_TEMP/askpass"
|
|
export GIT_ASKPASS="$RUNNER_TEMP/askpass" GIT_TERMINAL_PROMPT=0
|
|
git clone --depth 1 https://nandi@git.site.latha.org/nandi/cluster.git "$RUNNER_TEMP/cluster"
|
|
cd "$RUNNER_TEMP/cluster"
|
|
|
|
V=clusters/k3s-kplae-u30796/chandra-handset/values.yaml
|
|
sed -i "s/^\( *tag: \).*/\1\"${SHORT_SHA}\"/" $V
|
|
test "$(git diff --numstat | wc -l)" -le 1
|
|
|
|
# --atomic rolls back on failure, so the repo is only bumped for a deploy that worked. The phone has to be
|
|
# online. A compositor update then waits on the phone until it is idle or approved (handset/handset.sh).
|
|
helm upgrade --install chandra-handset charts/chandra-handset -n chandra-handset -f $V --atomic --wait --timeout 10m
|
|
kubectl -n chandra-handset get pods -o wide
|
|
|
|
if ! git diff --quiet; then
|
|
# nandi/cluster main is protected: push a branch, open a PR, and let Gitea merge it once its checks pass.
|
|
BRANCH="deploy/chandra-handset-${SHORT_SHA}"
|
|
TITLE="chore(chandra-handset): deploy ${SHORT_SHA}"
|
|
git -c user.name=ci -c user.email=ci@site.latha.org commit -am "$TITLE"
|
|
git push --force origin "HEAD:refs/heads/$BRANCH"
|
|
API=https://git.site.latha.org/api/v1/repos/nandi/cluster
|
|
printf 'Authorization: token %s\n' "$CLUSTER_REPO_TOKEN" > "$RUNNER_TEMP/auth-header"
|
|
api() { curl -fsS --retry 3 -H @"$RUNNER_TEMP/auth-header" -H 'Content-Type: application/json' "$@"; }
|
|
PR=$(api -X POST "$API/pulls" -d "{\"head\":\"$BRANCH\",\"base\":\"main\",\"title\":\"$TITLE\",\"body\":\"Image bump from $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID (already deployed).\"}" \
|
|
| node -e 'let d="";process.stdin.on("data",c=>d+=c).on("end",()=>console.log(JSON.parse(d).number))')
|
|
api -X POST "$API/pulls/$PR/merge" -d '{"Do":"merge","merge_when_checks_succeed":true,"delete_branch_after_merge":true}'
|
|
echo "Opened nandi/cluster PR #$PR (merges when its checks pass)"
|
|
fi
|