Cleanups and CI improvements
Validate, publish and deploy Gramps Web / validate (push) Successful in 23s
Validate, publish and deploy Gramps Web / ensure-postgresql-image (push) Successful in 37s
Validate, publish and deploy Gramps Web / publish (push) Successful in 18s
Validate, publish and deploy Gramps Web / deploy (push) Failing after 21s
Validate, publish and deploy Gramps Web / validate (push) Successful in 23s
Validate, publish and deploy Gramps Web / ensure-postgresql-image (push) Successful in 37s
Validate, publish and deploy Gramps Web / publish (push) Successful in 18s
Validate, publish and deploy Gramps Web / deploy (push) Failing after 21s
This commit is contained in:
1 parent
9933f9904a
commit
706d40ca97
6 files changed
+126
-28
No files matched your search
+57
-17
@@ -17,6 +17,7 @@ env:
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install pinned Helm
|
||||
@@ -33,19 +34,67 @@ jobs:
|
||||
| docker run --rm --interactive \
|
||||
ghcr.io/yannh/kubeconform:v0.7.0@sha256:85dbef6b4b312b99133decc9c6fc9495e9fc5f92293d4ff3b7e1b30f5611823c \
|
||||
-strict -exit-on-error -ignore-missing-schemas -summary
|
||||
- name: Build and test locale-enabled PostgreSQL
|
||||
|
||||
ensure-postgresql-image:
|
||||
if: gitea.event_name == 'push' && (gitea.ref == 'refs/heads/main' || startsWith(gitea.ref, 'refs/tags/v'))
|
||||
needs: validate
|
||||
# This trusted push-only job runs directly on the Podman-native runner.
|
||||
runs-on: linux_amd64
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Ensure locale-enabled PostgreSQL image exists
|
||||
env:
|
||||
BEFORE_SHA: ${{ gitea.event.before }}
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
GIT_REF: ${{ gitea.ref }}
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
base_version=$(docker run --rm docker.io/bitnami/postgresql:latest postgres --version)
|
||||
[[ "${base_version}" == *"PostgreSQL) 18."* ]]
|
||||
docker build --pull --tag "${POSTGRES_IMAGE}:ci" postgresql-image
|
||||
docker run --rm --entrypoint bash "${POSTGRES_IMAGE}:ci" -ec \
|
||||
test -n "${QUAY_USERNAME}"
|
||||
test -n "${QUAY_TOKEN}"
|
||||
authfile="${RUNNER_TEMP}/quay-auth.json"
|
||||
trap 'rm -f "${authfile}"' EXIT
|
||||
printf '%s' "${QUAY_TOKEN}" | podman login registry.brunner.ninja \
|
||||
--authfile "${authfile}" --username "${QUAY_USERNAME}" --password-stdin
|
||||
|
||||
build_required=false
|
||||
if ! podman manifest inspect --authfile "${authfile}" \
|
||||
"${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}" >/dev/null 2>&1; then
|
||||
echo "PostgreSQL image is not published yet."
|
||||
build_required=true
|
||||
elif [[ "${GIT_REF}" == refs/heads/main ]] \
|
||||
&& [[ "${BEFORE_SHA}" =~ ^[0-9a-f]{40}$ ]] \
|
||||
&& [[ ! "${BEFORE_SHA}" =~ ^0+$ ]] \
|
||||
&& ! git diff --quiet "${BEFORE_SHA}" "${COMMIT_SHA}" -- postgresql-image; then
|
||||
echo "PostgreSQL image recipe changed."
|
||||
build_required=true
|
||||
fi
|
||||
|
||||
if [[ "${build_required}" == false ]]; then
|
||||
echo "PostgreSQL image already exists; skipping the build."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
podman build --pull=always \
|
||||
--label "org.opencontainers.image.revision=${COMMIT_SHA}" \
|
||||
--label "org.opencontainers.image.source=https://code.brunner.ninja/feedc0de/gramps-kubernetes" \
|
||||
--tag "${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}" \
|
||||
postgresql-image
|
||||
podman run --rm --entrypoint bash \
|
||||
"${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}" -ec \
|
||||
'postgres --version | grep -E "PostgreSQL\) 18\."; locale -a | grep -Fx de_AT.utf8; locale -a | grep -Fx de_DE.utf8; locale -a | grep -Fx en_GB.utf8; locale -a | grep -Fx en_US.utf8'
|
||||
podman push --authfile "${authfile}" \
|
||||
"${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}"
|
||||
|
||||
publish:
|
||||
if: gitea.event_name == 'push' && (gitea.ref == 'refs/heads/main' || startsWith(gitea.ref, 'refs/tags/v'))
|
||||
needs: validate
|
||||
needs: [validate, ensure-postgresql-image]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install pinned Helm
|
||||
@@ -54,7 +103,7 @@ jobs:
|
||||
printf '%s %s\n' "${HELM_SHA256}" "${RUNNER_TEMP}/helm.tgz" | sha256sum --check
|
||||
tar -xzf "${RUNNER_TEMP}/helm.tgz" -C "${RUNNER_TEMP}" --strip-components=1 linux-amd64/helm
|
||||
echo "${RUNNER_TEMP}" >> "${GITHUB_PATH}"
|
||||
- name: Build and publish image and chart
|
||||
- name: Package and publish chart
|
||||
env:
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
GIT_REF: ${{ gitea.ref }}
|
||||
@@ -70,13 +119,6 @@ jobs:
|
||||
chart_version="0.0.0-dev.sha${COMMIT_SHA:0:12}"
|
||||
fi
|
||||
|
||||
base_version=$(docker run --rm docker.io/bitnami/postgresql:latest postgres --version)
|
||||
[[ "${base_version}" == *"PostgreSQL) 18."* ]]
|
||||
docker build --pull \
|
||||
--label "org.opencontainers.image.revision=${COMMIT_SHA}" \
|
||||
--label "org.opencontainers.image.source=https://code.brunner.ninja/feedc0de/gramps-web-deployment" \
|
||||
--tag "${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}" postgresql-image
|
||||
|
||||
helm dependency update .
|
||||
mkdir -p "${RUNNER_TEMP}/packages"
|
||||
helm package . --destination "${RUNNER_TEMP}/packages" \
|
||||
@@ -86,17 +128,15 @@ jobs:
|
||||
helm template gramps "${package}" --namespace gramps \
|
||||
--values values-arschrock.yaml > "${RUNNER_TEMP}/rendered.yaml"
|
||||
|
||||
printf '%s' "${QUAY_TOKEN}" | docker login registry.brunner.ninja \
|
||||
--username "${QUAY_USERNAME}" --password-stdin
|
||||
printf '%s' "${QUAY_TOKEN}" | helm registry login registry.brunner.ninja \
|
||||
--username "${QUAY_USERNAME}" --password-stdin
|
||||
docker push "${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}"
|
||||
helm push "${package}" "${CHART_REGISTRY}"
|
||||
|
||||
deploy:
|
||||
if: gitea.ref == 'refs/heads/main'
|
||||
needs: publish
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install pinned clients
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
name: Build locale-enabled PostgreSQL
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Refresh the moving Bitnami PostgreSQL 18 base image weekly.
|
||||
- cron: "23 3 * * 1"
|
||||
|
||||
env:
|
||||
POSTGRES_IMAGE: registry.brunner.ninja/feedc0de/postgres-with-locales
|
||||
POSTGRES_IMAGE_TAG: 18-locales
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Never run untrusted pull-request code directly on the host runner.
|
||||
runs-on: linux_amd64
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build and test image
|
||||
env:
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
podman build --pull=always \
|
||||
--label "org.opencontainers.image.revision=${COMMIT_SHA}" \
|
||||
--label "org.opencontainers.image.source=https://code.brunner.ninja/feedc0de/gramps-kubernetes" \
|
||||
--tag "${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}" \
|
||||
postgresql-image
|
||||
podman run --rm --entrypoint bash "${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}" -ec \
|
||||
'postgres --version | grep -E "PostgreSQL\) 18\."; locale -a | grep -Fx de_AT.utf8; locale -a | grep -Fx de_DE.utf8; locale -a | grep -Fx en_GB.utf8; locale -a | grep -Fx en_US.utf8'
|
||||
- name: Publish image
|
||||
if: gitea.event_name != 'pull_request'
|
||||
env:
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -n "${QUAY_USERNAME}"
|
||||
test -n "${QUAY_TOKEN}"
|
||||
authfile="${RUNNER_TEMP}/quay-auth.json"
|
||||
trap 'rm -f "${authfile}"' EXIT
|
||||
printf '%s' "${QUAY_TOKEN}" | podman login registry.brunner.ninja \
|
||||
--authfile "${authfile}" --username "${QUAY_USERNAME}" --password-stdin
|
||||
podman push --authfile "${authfile}" \
|
||||
"${POSTGRES_IMAGE}:${POSTGRES_IMAGE_TAG}"
|
||||
@@ -179,10 +179,23 @@ kubectl apply -f ci-deployer.yaml
|
||||
./create-ci-kubeconfig.sh # save its output as Gitea KUBE_CONFIG_BASE64
|
||||
```
|
||||
|
||||
Also configure `QUAY_USERNAME` and `QUAY_TOKEN` in Gitea. CI validates the
|
||||
chart, builds and tests the locale-enabled PostgreSQL 18 image, publishes the
|
||||
OCI chart to `registry.brunner.ninja/feedc0de/charts/gramps-web`, and deploys
|
||||
that exact chart package to the `gramps` namespace from the registry.
|
||||
Also configure `QUAY_USERNAME` and `QUAY_TOKEN` in Gitea. The chart workflow
|
||||
validates the chart, publishes it to
|
||||
`registry.brunner.ninja/feedc0de/charts/gramps-web`, and deploys that exact
|
||||
package to the `gramps` namespace. The registry credentials are used by CI for
|
||||
publishing and reading the OCI chart; the public PostgreSQL image needs no
|
||||
Kubernetes image-pull Secret. Before publishing the chart, a trusted host job
|
||||
checks that the configured PostgreSQL image exists and builds it once with
|
||||
native Podman if the repository is still empty. Ordinary chart changes
|
||||
therefore do not rebuild PostgreSQL.
|
||||
|
||||
The ordered main workflow also rebuilds the image when `postgresql-image/`
|
||||
changes. A separate refresh workflow runs when manually dispatched and on a
|
||||
weekly schedule so the moving Bitnami PostgreSQL 18 base receives updates. It
|
||||
uses native Podman on the host runner and publishes
|
||||
`registry.brunner.ninja/feedc0de/postgres-with-locales:18-locales`.
|
||||
Generating each locale is time-bounded, and the job itself has a 20-minute
|
||||
timeout so a broken upstream image cannot occupy the runner indefinitely.
|
||||
|
||||
This deployment stores Helm release metadata in ConfigMaps. The CI identity
|
||||
cannot list Secrets or read `gramps-runtime` (OIDC, S3, database URIs, and app
|
||||
|
||||
@@ -4,9 +4,9 @@ FROM ${BASE_IMAGE}
|
||||
USER 0
|
||||
ARG LOCALES="de_AT de_DE en_GB en_US"
|
||||
RUN for locale_name in ${LOCALES}; do \
|
||||
localedef --force --inputfile="${locale_name}" --charmap=UTF-8 "${locale_name}.UTF-8"; \
|
||||
done \
|
||||
&& tdnf clean all
|
||||
timeout 30s localedef --force \
|
||||
--inputfile="${locale_name}" --charmap=UTF-8 "${locale_name}.UTF-8"; \
|
||||
done
|
||||
|
||||
ENV LANG=en_US.UTF-8 \
|
||||
LANGUAGE=en_US:en
|
||||
|
||||
@@ -50,8 +50,9 @@ if grep -Eq '^kind: StatefulSet$' "${workdir}/external.yaml"; then
|
||||
fi
|
||||
|
||||
# Block the credential patterns that existed in the legacy raw manifests.
|
||||
if rg --hidden --glob '!charts/**' --glob '!postgresql/**' --glob '!valkey/**' \
|
||||
--glob '!test.sh' \
|
||||
if grep --recursive --extended-regexp --line-number \
|
||||
--exclude-dir=.git --exclude-dir=charts --exclude-dir=postgresql \
|
||||
--exclude-dir=valkey --exclude=test.sh \
|
||||
'(GRAMPSWEB_POSTGRES_PASSWORD:[[:space:]]+[^{$]|OIDC_CLIENT_SECRET:[[:space:]]+[^{$]|AWS_SECRET_ACCESS_KEY:[[:space:]]+[^{$]|password:[[:space:]]+[A-Za-z0-9]{24,})' \
|
||||
"${project_dir}"; then
|
||||
echo "A likely plaintext credential is present in committable chart sources" >&2
|
||||
|
||||
@@ -95,8 +95,6 @@ postgresql:
|
||||
repository: feedc0de/postgres-with-locales
|
||||
tag: 18-locales
|
||||
pullPolicy: Always
|
||||
pullSecrets:
|
||||
- quay-pull-secret
|
||||
auth:
|
||||
username: gramps
|
||||
database: gramps
|
||||
|
||||
Reference in new issue
Block a user