Commit 773c2674 authored by Brian Long's avatar Brian Long
Browse files

added gitea workflow

parent ef6f8e10
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
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 }}
+37 −0
Original line number Diff line number Diff line
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 }}
+59 −0
Original line number Diff line number Diff line
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}
+47 −0
Original line number Diff line number Diff line
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 }}
+35 −0
Original line number Diff line number Diff line
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 }}
+1 −1

File changed.

Contains only whitespace changes.

Loading