Files
CoqDecks/.gitea/workflows/build.yaml
T
claude 4954471aac
Build and push CoqDecks / build (push) Has been cancelled
Fix submodule SSH URL by rewriting .gitmodules before sync
git config insteadOf is not picked up by submodule update in this
environment; rewrite .gitmodules directly and run submodule sync to
propagate the HTTPS URL before fetching.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 21:40:13 +00:00

113 lines
4.4 KiB
YAML

name: Build and push CoqDecks
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: native
timeout-minutes: 120
steps:
- name: Build and push CoqDecks images with BuildKit
run: |
kubectl -n ci delete job coqdecks-buildkit --ignore-not-found=true --wait=true
BRANCH=${GITEA_REF_NAME:-${GITHUB_REF_NAME:-main}}
cat <<'EOF' | sed "s|__BRANCH__|${BRANCH}|g" | kubectl apply -f -
apiVersion: batch/v1
kind: Job
metadata:
name: coqdecks-buildkit
namespace: ci
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
initContainers:
- name: prepare
image: alpine/git:latest
command: ["sh", "-c"]
args:
- |
set -eux
git clone --depth 1 --branch __BRANCH__ https://git.alocoq.fr/alois/CoqDecks.git /workspace/repo
cd /workspace/repo
sed -i 's|git@github.com:|https://github.com/|g' .gitmodules
git submodule sync
git submodule update --init --depth 1
volumeMounts:
- name: workspace
mountPath: /workspace
containers:
- name: buildkit
image: moby/buildkit:latest
securityContext:
privileged: true
command: ["sh", "-c"]
args:
- |
set -eux
REG=registry.git.svc.cluster.local:5000
mkdir -p /etc/buildkit
printf '[registry."%s"]\n http = true\n insecure = true\n' "$REG" > /etc/buildkit/buildkitd.toml
# Only pass --import-cache when the tag already exists in the
# registry. On first run the tag is absent and some registries
# time out rather than returning 404, which makes buildctl exit
# non-zero even though the build and push succeeded.
cache_flag() {
local image="$1" tag="$2"
if wget -qO- "http://$REG/v2/$image/tags/list" 2>/dev/null | grep -q "\"$tag\""; then
echo "--import-cache type=registry,ref=$REG/$image:$tag"
fi
}
# Build server image
buildctl-daemonless.sh build \
--frontend=dockerfile.v0 \
--local context=/workspace/repo/server \
--local dockerfile=/workspace/repo/server \
$(cache_flag coqdecks-cache server) \
--export-cache type=registry,ref=$REG/coqdecks-cache:server,mode=max \
--output type=image,name=$REG/coqdecks-server:latest,push=true,registry.insecure=true
# Build client image
buildctl-daemonless.sh build \
--frontend=dockerfile.v0 \
--local context=/workspace/repo/client \
--local dockerfile=/workspace/repo/client \
$(cache_flag coqdecks-cache client) \
--export-cache type=registry,ref=$REG/coqdecks-cache:client,mode=max \
--output type=image,name=$REG/coqdecks-client:latest,push=true,registry.insecure=true
volumeMounts:
- name: workspace
mountPath: /workspace
volumes:
- name: workspace
emptyDir: {}
EOF
- name: Wait for build
run: |
kubectl -n ci wait --for=condition=complete job/coqdecks-buildkit --timeout=7200s
- name: Show build logs
if: always()
run: |
kubectl -n ci logs job/coqdecks-buildkit -c prepare || true
kubectl -n ci logs job/coqdecks-buildkit -c buildkit || true
- name: Cleanup
if: always()
run: |
kubectl -n ci delete job coqdecks-buildkit --ignore-not-found=true --wait=true