Files
software-infrastructure/.gitea/workflows/ci-tools-image.yaml
claudeandClaude Opus 5.5 1b197efc64 G1: shared CI tools image (prepared, not yet built in CI)
Add images/ci-tools: one image with ansible 14.6.0 (core 2.21.6),
ansible-lint, yamllint, helm 3.22.1, kubeconform, actionlint, hadolint,
gitleaks and node 24 for JavaScript actions. Python tools are pinned in
requirements.txt; binaries are pinned by version and the SHA-256 from
each release's checksum file. VERSION starts at 1.0.0.

Add a manual-only ci-tools-image workflow that builds and smoke-tests
the image, and publishes an immutable version tag only when Eric enables
CI_TOOLS_PUBLISH and adds a registry token (after S8 and P1). A sample
job then uses the published image as its container.

Tested on the workstation: image builds, every tool reports its pinned
version, hadolint/actionlint pass on the new files, and syntax-check
passes for gitea.yaml, ci-runner.yaml and prometheus.yaml inside it.

Refs DevOps/software-infrastructure#49

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 09:16:28 -05:00

120 lines
4.4 KiB
YAML

# Build, smoke-test and (once allowed) publish the shared CI tools image.
# DevOps/software-infrastructure#49 (G1). Source: images/ci-tools/.
#
# Manual-only for now: the shared runner is still being stabilised (S3-S8,
# #36-#41), so this must not start on every push. After S8 passes, add:
#
# push:
# branches: [main]
# paths: ["images/ci-tools/**", ".gitea/workflows/ci-tools-image.yaml"]
#
# Publishing also needs P1 (#61) and two settings Eric creates on this repo:
# variable CI_TOOLS_PUBLISH = "true"
# secret REGISTRY_TOKEN = a token with write:package for the publishing user
# variable REGISTRY_USER = that user's name
# Without them the publish and sample jobs are skipped and nothing is pushed.
name: ci-tools-image
on:
workflow_dispatch:
concurrency:
group: ci-tools-image-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE: gitea.eom.dev/devops/ci-tools
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- name: Read version
id: version
run: |
version="$(tr -d '[:space:]' < images/ci-tools/VERSION)"
if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::images/ci-tools/VERSION must be MAJOR.MINOR.PATCH, got '$version'"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
# The build context is sent over the Docker API, so this works even
# though the runner's Docker daemon can't see the job's files.
- name: Build
run: docker build -t "ci-tools:ci-${{ github.run_id }}" images/ci-tools
- name: Smoke test (every tool present at its pinned version)
run: docker run --rm "ci-tools:ci-${{ github.run_id }}" ci-tools-versions
- name: Lint the image's own Dockerfile with the image
run: docker run --rm -i "ci-tools:ci-${{ github.run_id }}" hadolint - < images/ci-tools/Dockerfile
- name: Clean up
if: always()
run: docker image rm "ci-tools:ci-${{ github.run_id }}" >/dev/null 2>&1 || true
publish:
needs: build
if: vars.CI_TOOLS_PUBLISH == 'true' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
image: ${{ steps.push.outputs.image }}
env:
VERSION: ${{ needs.build.outputs.version }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- name: Log in to the Gitea registry
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
REGISTRY_USER: ${{ vars.REGISTRY_USER }}
run: printf '%s' "$REGISTRY_TOKEN" | docker login gitea.eom.dev -u "$REGISTRY_USER" --password-stdin
# Version tags are immutable: bump images/ci-tools/VERSION to publish.
- name: Refuse to overwrite an existing version
run: |
if docker manifest inspect "$IMAGE:$VERSION" >/dev/null 2>&1; then
echo "::error::$IMAGE:$VERSION already exists. Bump images/ci-tools/VERSION."
exit 1
fi
- name: Build and push
id: push
run: |
docker build \
--label "org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}" \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--label "org.opencontainers.image.version=$VERSION" \
-t "$IMAGE:$VERSION" images/ci-tools
docker run --rm "$IMAGE:$VERSION" ci-tools-versions
docker push "$IMAGE:$VERSION"
echo "image=$IMAGE:$VERSION" >> "$GITHUB_OUTPUT"
- name: Log out and clean up
if: always()
run: |
docker logout gitea.eom.dev || true
docker image rm "$IMAGE:$VERSION" >/dev/null 2>&1 || true
# Acceptance check for G1: a job that uses the published image as its
# container starts and runs the tools without installing anything.
sample:
needs: publish
runs-on: ubuntu-latest
timeout-minutes: 10
container:
image: ${{ needs.publish.outputs.image }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- run: ci-tools-versions
- run: actionlint -color .gitea/workflows/ci-tools-image.yaml
- run: yamllint -d relaxed .gitea/workflows/ci-tools-image.yaml