Files
tool-evaluator/.gitea/workflows/build.yaml
T
opencode 803802a5b6
Build & Push Docker Image / build (push) Successful in 2m36s
feat: show live build version in web UI
- /api/version returns version, commitSha, buildDate, trashRetentionDays
- CI passes COMMIT_SHA (full), BUILD_DATE and VERSION (git tag) as
  docker build args; Dockerfile bakes them as env
- sidebar footer shows version/sha linked to the Gitea commit
- admin System tab shows version, commit link, build date, trash retention
2026-08-02 02:13:27 +02:00

55 lines
1.8 KiB
YAML

name: Build & Push Docker Image
run-name: Build ${{ gitea.ref_name }}
on:
push:
branches: [main]
tags: ["v*"]
jobs:
build:
runs-on: ubuntu-latest
env:
DOCKER_HOST: tcp://172.17.0.1:2375
steps:
- uses: actions/checkout@v4
- name: Install Docker CLI
run: |
apt-get update -qq
apt-get install -y -qq docker.io
docker version
- name: Log in to Gitea Container Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.kubebase.de -u ${{ secrets.REGISTRY_USER }} --password-stdin
- name: Build and push
run: |
SHA=$(git rev-parse --short HEAD)
FULL_SHA=$(git rev-parse HEAD)
IMAGE="git.kubebase.de/${{ gitea.repository }}"
if [ "${{ gitea.ref_type }}" = "tag" ]; then VERSION="${{ gitea.ref_name }}"; else VERSION=""; fi
docker build --no-cache \
--build-arg COMMIT_SHA="$FULL_SHA" \
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--build-arg VERSION="$VERSION" \
-t "${IMAGE}:sha-${SHA}" -t "${IMAGE}:latest" .
docker push "${IMAGE}:sha-${SHA}"
docker push "${IMAGE}:latest"
- name: Update k8s manifest in admin/apps
env:
GITEA_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
SHA=$(git rev-parse --short HEAD)
git clone "https://admin:${GITEA_TOKEN}@git.kubebase.de/admin/apps.git" /tmp/apps
cd /tmp/apps
cd apps/system/toolrate/overlays/k3s
sed -i "s|newTag: .*|newTag: sha-${SHA}|" kustomization.yaml
git config user.name "Gitea Actions"
git config user.email "actions@git.kubebase.de"
git add -A
git diff --cached --quiet || git commit -m "chore: update toolrate image to sha-${SHA}"
git push