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:
3 files changed
+28
-89
No files matched your search
+24
-85
@@ -10,96 +10,35 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: "0 16 * * FRI"
|
- 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:
|
jobs:
|
||||||
changes:
|
build:
|
||||||
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' }}
|
|
||||||
runs-on: job-v2
|
runs-on: job-v2
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- 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
|
- name: Build
|
||||||
id: build
|
run: |
|
||||||
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
|
for image in $IMAGES; do
|
||||||
with:
|
pull=missing; [[ $image == base ]] && pull=newer
|
||||||
image: job79/base
|
buildah build --pull="$pull" --platform linux/amd64 \
|
||||||
tags: ${{ github.ref_name }}
|
--build-arg TAG="$TAG" \
|
||||||
context: ./containers/base
|
-t "$REGISTRY/job79/$image:$TAG" "containers/$image"
|
||||||
containerfiles: ./containers/base/Containerfile
|
done
|
||||||
platforms: linux/amd64
|
|
||||||
|
|
||||||
- name: Push
|
- name: Push
|
||||||
uses: redhat-actions/push-to-registry@v2
|
if: env.PUSH == 'true'
|
||||||
with:
|
env:
|
||||||
image: ${{ steps.build.outputs.image }}
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
tags: ${{ steps.build.outputs.tags }}
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
registry: git.plabble.org
|
run: |
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
buildah login -u "$REGISTRY_USERNAME" --password-stdin "$REGISTRY" <<<"$REGISTRY_TOKEN"
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
for image in $IMAGES; do
|
||||||
extra-args: |
|
buildah push --compression-format=zstd --compression-level=12 "$REGISTRY/job79/$image:$TAG"
|
||||||
--compression-format=zstd
|
done
|
||||||
--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
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
ARG TAG
|
ARG TAG=main
|
||||||
FROM job79/base:${TAG}
|
FROM git.plabble.org/job79/base:${TAG}
|
||||||
USER root
|
USER root
|
||||||
|
|
||||||
RUN set -o pipefail && \
|
RUN set -o pipefail && \
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
ARG TAG
|
ARG TAG=main
|
||||||
FROM job79/base:${TAG}
|
FROM git.plabble.org/job79/base:${TAG}
|
||||||
Reference in new issue
Block a user