ci: simplify container build workflow

- Drop the changes job; the on.paths filter already does this.
- Build all images in one job with buildah, so dependent images use the
  freshly built local base instead of pulling it.
- Only push outside of pull requests; PR builds use a pr-<n> tag.
- Reference the base image by its full registry path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-08 11:46:59 +01:00
1 parent 9c6569fa29
commit 12534d3afd
3 files changed
+28 -89

No files matched your search

+24 -85
View File
@@ -10,96 +10,35 @@ on:
schedule:
- cron: "0 16 * * FRI"
env:
REGISTRY: git.plabble.org
# Images in build order; later images build FROM the local base image.
IMAGES: base go infra
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref_name }}
PUSH: ${{ github.event_name != 'pull_request' }}
jobs:
changes:
runs-on: job-v2
outputs:
any_container_change: ${{ steps.filter.outputs.containers == 'true' || steps.filter.outputs.workflow == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: https://github.com/dorny/paths-filter@v3
id: filter
with:
filters: |
workflow: ['.gitea/workflows/build.yaml']
containers: ['containers/**']
base-image:
needs: [changes]
if: ${{ needs.changes.outputs.any_container_change == 'true' }}
build:
runs-on: job-v2
steps:
- uses: actions/checkout@v6
- name: Log in
uses: redhat-actions/podman-login@v1
with:
registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build
id: build
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
with:
image: job79/base
tags: ${{ github.ref_name }}
context: ./containers/base
containerfiles: ./containers/base/Containerfile
platforms: linux/amd64
run: |
for image in $IMAGES; do
pull=missing; [[ $image == base ]] && pull=newer
buildah build --pull="$pull" --platform linux/amd64 \
--build-arg TAG="$TAG" \
-t "$REGISTRY/job79/$image:$TAG" "containers/$image"
done
- name: Push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
extra-args: |
--compression-format=zstd
--compression-level=12
dependent-images:
needs: [changes, base-image]
if: ${{ needs.changes.outputs.any_container_change == 'true' }}
runs-on: job-v2
strategy:
fail-fast: false
matrix:
container: [infra, go]
steps:
- name: Clone repo
uses: actions/checkout@v6
- name: Log in
uses: redhat-actions/podman-login@v1
with:
registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build
id: build
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
with:
image: job79/${{ matrix.container }}
tags: ${{ github.ref_name }}
context: ./containers/${{ matrix.container }}
containerfiles: ./containers/${{ matrix.container }}/Containerfile
build-args: TAG=${{ github.ref_name }}
platforms: linux/amd64
- name: Push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: git.plabble.org
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
extra-args: |
--compression-format=zstd
--compression-level=12
if: env.PUSH == 'true'
env:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
buildah login -u "$REGISTRY_USERNAME" --password-stdin "$REGISTRY" <<<"$REGISTRY_TOKEN"
for image in $IMAGES; do
buildah push --compression-format=zstd --compression-level=12 "$REGISTRY/job79/$image:$TAG"
done
+2 -2
View File
@@ -1,5 +1,5 @@
ARG TAG
FROM job79/base:${TAG}
ARG TAG=main
FROM git.plabble.org/job79/base:${TAG}
USER root
RUN set -o pipefail && \
+2 -2
View File
@@ -1,2 +1,2 @@
ARG TAG
FROM job79/base:${TAG}
ARG TAG=main
FROM git.plabble.org/job79/base:${TAG}