From 773c2674d6e3d2b84d10d1cc90fabbf6dd20b641 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Tue, 8 Sep 2026 08:53:09 -0400 Subject: [PATCH] added gitea workflow --- .gitea/actions/containerd-build/action.yml | 57 +++++++++++++++++++++ .gitea/actions/containerd-debug/action.yml | 37 ++++++++++++++ .gitea/actions/containerd-push/action.yml | 59 ++++++++++++++++++++++ .gitea/actions/skopeo-inspect/action.yml | 47 +++++++++++++++++ .gitea/workflows/ci.yaml | 35 +++++++++++++ README.md | 2 +- 6 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 .gitea/actions/containerd-build/action.yml create mode 100644 .gitea/actions/containerd-debug/action.yml create mode 100644 .gitea/actions/containerd-push/action.yml create mode 100644 .gitea/actions/skopeo-inspect/action.yml create mode 100644 .gitea/workflows/ci.yaml diff --git a/.gitea/actions/containerd-build/action.yml b/.gitea/actions/containerd-build/action.yml new file mode 100644 index 0000000..dee5903 --- /dev/null +++ b/.gitea/actions/containerd-build/action.yml @@ -0,0 +1,57 @@ +name: containerd-build +description: Builds a containerd image. +inputs: + registry_host: + description: A containerd registry host. + required: false + default: ${{ vars.INTELIGR8_REGISTRY_HOST }} + image_namespace: + description: A containerd image prefix. + required: false + default: ${{ vars.INTELIGR8_IMAGE_NAMESPACE }} + image_name: + description: A containerd image name, without the host and prefix. + required: true + build_opts: + description: A string of options for the containerd CLI build command. + required: false + default: --quiet +runs: + using: "composite" + steps: + - id: containerd_debug + uses: ./.gitea/actions/containerd-debug + - id: skopeo_inspect + uses: ./.gitea/actions/skopeo-inspect + with: + image_name: base-runner + - id: containerd_build + working-directory: containerd + env: + REGISTRY_HOST: ${{ inputs.registry_host }} + IMAGE_NAMESPACE: ${{ inputs.image_namespace }} + IMAGE_NAME: ${{ inputs.image_name }} + CONTAINERD_CMD: buildah + CONTAINERD_BUILD_FORMAT: docker + CONTAINERD_BUILD_OPTS: ${{ inputs.build_opts }} + CONTAINERD_CMD_DEBUG_OPTS: ${{ steps.containerd_debug.outputs.containerd_cmd_debug_opts }} + CONTAINERD_IMAGE_EXISTS: ${{ steps.skopeo_inspect.outputs.image_exists }} + shell: bash + run: | + if (( ${CONTAINERD_IMAGE_EXISTS} == "true" )); then + echo "Container image already built; skipping rebuild" + else + GIT_COMMIT_SHORT_SHA=${GITHUB_SHA::8} + IMAGE_REMOTE_NAME=${REGISTRY_HOST}/${IMAGE_NAMESPACE}${IMAGE_NAME} + + echo "image_tag=sha${GIT_COMMIT_SHORT_SHA}" >> $GITHUB_OUTPUT + + echo "Building container image" + ${CONTAINERD_CMD} ${CONTAINERD_CMD_OPTS} ${CONTAINERD_CMD_DEBUG_OPTS} build \ + --format=${CONTAINERD_BUILD_FORMAT} \ + ${CONTAINERD_BUILD_OPTS} \ + --tag ${IMAGE_REMOTE_NAME}:sha${GIT_COMMIT_SHORT_SHA} +outputs: + image_tag: + description: The resultant containerd image tag. + value: ${{ steps.containerd_build.outputs.image_tag }} diff --git a/.gitea/actions/containerd-debug/action.yml b/.gitea/actions/containerd-debug/action.yml new file mode 100644 index 0000000..248697d --- /dev/null +++ b/.gitea/actions/containerd-debug/action.yml @@ -0,0 +1,37 @@ +name: containerd-debug +description: Conditionally enable debug for containerd related executions. +inputs: + debug: + description: Enable debug? + required: false + default: ${{ vars.CONTAINERD_DEBUG }} +runs: + using: "composite" + steps: + - id: skopeo_debug + name: Enable skopeo debugging + env: + DEBUG: ${{ inputs.debug }} + shell: bash + run: | + if [[ ! -z ${DEBUG} ]]; then + echo "SKOPEO_OPTS=\"${SKOPEO_OPTS} --debug\"" >> $GITHUB_ENV + echo "skopeo_debug_opts=\"--debug\"" >> $GITHUB_OUTPUT + fi + - id: containerd_debug + name: Enable containerd debugging + env: + DEBUG: ${{ inputs.debug }} + shell: bash + run: | + if [[ ! -z ${DEBUG} ]]; then + echo "CONTAINERD_CMD_OPTS=\"${CONTAINERD_CMD_OPTS} --log-level=debug\"" >> $GITHUB_ENV + echo "containerd_cmd_debug_opts=\"--log-level=debug\"" >> $GITHUB_OUTPUT + fi +outputs: + skopeo_debug_opts: + description: empty if no debug; otherwise debug enablement options for the `skopeo` CLI command. + value: ${{ steps.skopeo_debug.outputs.skopeo_debug_opts }} + containerd_cmd_debug_opts: + description: empty if no debug; otherwise debug enablement options for the containerd CLI command. + value: ${{ steps.containerd_debug.outputs.containerd_cmd_debug_opts }} diff --git a/.gitea/actions/containerd-push/action.yml b/.gitea/actions/containerd-push/action.yml new file mode 100644 index 0000000..da2e0fc --- /dev/null +++ b/.gitea/actions/containerd-push/action.yml @@ -0,0 +1,59 @@ +name: containerd-build +description: Pushes a containerd image. +inputs: + registry_host: + description: A containerd registry host. + required: false + default: ${{ vars.INTELIGR8_REGISTRY_HOST }} + image_namespace: + description: A containerd image prefix. + required: false + default: ${{ vars.INTELIGR8_IMAGE_NAMESPACE }} + image_name: + description: A containerd image name, without the host and prefix. + required: true + target_image_tag: + description: A new tag for the specified containerd image. + required: false + push_opts: + description: A string of options for the containerd CLI build command. + required: false + default: --quiet +runs: + using: "composite" + steps: + - id: containerd_debug + uses: ./.gitea/actions/containerd-debug + - id: containerd_push + working-directory: containerd + env: + REGISTRY_HOST: ${{ inputs.registry_host }} + IMAGE_NAMESPACE: ${{ inputs.image_namespace }} + IMAGE_NAME: ${{ inputs.image_name }} + TARGET_IMAGE_TAG: ${{ inputs.target_image_tag }} + CONTAINERD_CMD: buildah + CONTAINERD_PUSH_OPTS: ${{ inputs.push_opts }} + CONTAINERD_CMD_DEBUG_OPTS: ${{ steps.containerd_debug.outputs.containerd_cmd_debug_opts }} + shell: bash + run: | + IMAGE_REMOTE_NAME=${REGISTRY_HOST}/${IMAGE_NAMESPACE}${IMAGE_NAME} + + if [[ -z ${TARGET_IMAGE_TAG} ]]; then + GIT_COMMIT_SHORT_SHA=${GITHUB_SHA::8} + echo "Pushing container image to registry with commit SHA: ${GIT_COMMIT_SHORT_SHA}" + TARGET_IMAGE_TAG=sha${GIT_COMMIT_SHORT_SHA} + else + SOURCE_IMAGE_TAG=sha${GIT_COMMIT_SHORT_SHA} + echo "Synchronizing container image from registry for tag: ${SOURCE_IMAGE_TAG}" + ${CONTAINERD_CMD} ${CONTAINERD_CMD_OPTS} pull \ + ${CONTAINERD_IMAGE_REMOTE_NAME}:${SOURCE_IMAGE_TAG} + + echo "Tagging container image to registry with version: ${TARGET_IMAGE_TAG}" + ${CONTAINERD_CMD} ${CONTAINERD_CMD_OPTS} ${CONTAINERD_CMD_DEBUG_OPTS} tag \ + ${CONTAINERD_IMAGE_REMOTE_NAME}:${SOURCE_IMAGE_TAG} \ + ${CONTAINERD_IMAGE_REMOTE_NAME}:${TARGET_IMAGE_TAG} + fi + + ${CONTAINERD_CMD} ${CONTAINERD_CMD_OPTS} ${CONTAINERD_CMD_DEBUG_OPTS} push \ + ${CONTAINERD_PUSH_OPTS} \ + ${IMAGE_REMOTE_NAME}:${TARGET_IMAGE_TAG} diff --git a/.gitea/actions/skopeo-inspect/action.yml b/.gitea/actions/skopeo-inspect/action.yml new file mode 100644 index 0000000..46e122a --- /dev/null +++ b/.gitea/actions/skopeo-inspect/action.yml @@ -0,0 +1,47 @@ +name: skopeo-inspect +description: Check for the existence of a containerd image. +inputs: + registry_host: + description: A containerd registry host. + required: false + default: ${{ vars.INTELIGR8_REGISTRY_HOST }} + image_namespace: + description: A containerd image prefix. + required: false + default: ${{ vars.INTELIGR8_IMAGE_NAMESPACE }} + image_name: + description: A containerd image name, without the host and prefix. + required: true +runs: + using: "composite" + steps: + - id: containerd_debug + uses: ./.gitea/actions/containerd-debug + - id: skopeo_inspect + env: + REGISTRY_HOST: ${{ inputs.registry_host }} + IMAGE_NAMESPACE: ${{ inputs.image_namespace }} + IMAGE_NAME: ${{ inputs.image_name }} + SKOPEO_DEBUG_OPTS: ${{ steps.containerd_debug.outputs.skopeo_debug_opts }} + shell: bash + run: | + GIT_COMMIT_SHORT_SHA=${GITHUB_SHA::8} + IMAGE_REMOTE_NAME=${REGISTRY_HOST}/${IMAGE_NAMESPACE}${IMAGE_NAME} + + set +e + echo "Checking for image: ${IMAGE_REMOTE_NAME}:sha${GIT_COMMIT_SHORT_SHA}" + skopeo ${SKOPEO_OPTS} ${SKOPEO_DEBUG_OPTS} inspect docker://${IMAGE_REMOTE_NAME}:sha${GIT_COMMIT_SHORT_SHA} + SKOPEO_INSPECT_RC=$? + set -e + + if (( ${SKOPEO_INSPECT_RC} == 0 )); then + echo "Found image: ${IMAGE_REMOTE_NAME}:sha${GIT_COMMIT_SHORT_SHA}" + echo "image_exists=true" >> $GITHUB_OUTPUT + else + echo "Could not find image: ${IMAGE_REMOTE_NAME}:sha${GIT_COMMIT_SHORT_SHA}" + echo "image_exists=false" >> $GITHUB_OUTPUT + fi +outputs: + image_exists: + description: `true` if the containerd image exists; `false` otherwise + value: ${{ steps.skopeo_inspect.outputs.image_exists }} diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..24247a3 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,35 @@ +name: Base Runner +on: [push] + +env: + DEBIAN_VERSION: stable-20260824 + +jobs: + Containerd-Build: + runs-on: containerd + steps: + - uses: https://git.inteligr8.com/inteligr8/git-actions/checkout@stable + - id: containerd_build + uses: ./.gitea/actions/containerd-build + with: + image_name: base-runner + build_opts: --build-arg DEBIAN_VERSION=${{ env.DEBIAN_VERSION }} + Containerd-Push-Sha: + runs-on: containerd + needs: Containerd-Build + steps: + - uses: https://git.inteligr8.com/inteligr8/git-actions/checkout@stable + - id: containerd_push_sha + uses: ./.gitea/actions/containerd-push + with: + image_name: base-runner + Containerd-Push-Ref: + runs-on: containerd + needs: Containerd-Build + steps: + - uses: https://git.inteligr8.com/inteligr8/git-actions/checkout@stable + - id: containerd_push_ref + uses: ./.gitea/actions/containerd-push + with: + image_name: base-runner + target_image_tag: ${{ gitea.ref_name }} diff --git a/README.md b/README.md index 8437c16..5747cce 100644 --- a/README.md +++ b/README.md @@ -107,4 +107,4 @@ You are welcome to copy the repository, but please open an issue first to avoid ## References -- [Debian Slim](https://github.com/linuxcontainers/debian-slim) \ No newline at end of file +- [Debian Slim](https://github.com/linuxcontainers/debian-slim)