2023-02-03 07:05:11 +01:00
|
|
|
name: Build images (RedHat)
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
2024-02-14 09:25:33 +01:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- '[0-9]+.[0-9]+'
|
|
|
|
- 'trunk'
|
|
|
|
paths:
|
|
|
|
- 'Dockerfiles/*/rhel/*'
|
|
|
|
- 'build.json'
|
|
|
|
- '!**/README.md'
|
|
|
|
- '.github/workflows/images_build_rhel.yml'
|
2024-02-11 09:12:08 +01:00
|
|
|
workflow_dispatch:
|
2024-02-14 11:02:56 +01:00
|
|
|
inputs:
|
|
|
|
publish_images:
|
|
|
|
description: 'Publish images'
|
|
|
|
required: true
|
|
|
|
default: false
|
|
|
|
type: boolean
|
2024-05-08 09:05:28 +02:00
|
|
|
trunk_version:
|
|
|
|
description: 'Specify trunk major version'
|
|
|
|
type: string
|
2023-02-03 07:05:11 +01:00
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
2024-02-11 16:49:23 +01:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
env:
|
2024-02-19 06:57:53 +01:00
|
|
|
TRUNK_ONLY_EVENT: ${{ contains(fromJSON('["schedule"]'), github.event_name) }}
|
2024-05-08 09:29:42 +02:00
|
|
|
AUTO_PUSH_IMAGES: ${{ (! contains(fromJSON('["push"]'), github.event_name) && vars.AUTO_PUSH_IMAGES) || (contains(fromJSON('["workflow_dispatch"]'), github.event_name) && inputs.publish_images == 'true' ) }}
|
2023-02-03 07:05:11 +01:00
|
|
|
LATEST_BRANCH: ${{ github.event.repository.default_branch }}
|
2024-02-11 10:07:29 +01:00
|
|
|
TRUNK_GIT_BRANCH: "refs/heads/trunk"
|
2024-02-11 09:12:08 +01:00
|
|
|
IMAGES_PREFIX: "zabbix-"
|
2023-02-03 07:05:11 +01:00
|
|
|
BASE_BUILD_NAME: "build-base"
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-14 09:25:33 +01:00
|
|
|
MATRIX_FILE: "build.json"
|
2024-02-11 09:12:08 +01:00
|
|
|
DOCKERFILES_DIRECTORY: "Dockerfiles"
|
|
|
|
|
|
|
|
OIDC_ISSUER: "https://token.actions.githubusercontent.com"
|
|
|
|
IDENITY_REGEX: "https://github.com/zabbix/zabbix-docker/.github/"
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
REGISTRY: "quay.io"
|
|
|
|
REGISTRY_NAMESPACE: "redhat-isv-containers"
|
2024-02-11 09:12:08 +01:00
|
|
|
PREFLIGHT_IMAGE: "quay.io/opdev/preflight:stable"
|
2023-02-03 07:05:11 +01:00
|
|
|
PFLT_LOGLEVEL: "warn"
|
|
|
|
PFLT_ARTIFACTS: "/tmp/artifacts"
|
2024-02-14 18:56:07 +01:00
|
|
|
IMAGE_DIR: "/tmp/images"
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
RHEL_BUILD: "true"
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
jobs:
|
|
|
|
init_build:
|
|
|
|
name: Initialize build
|
2024-02-11 09:12:08 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
2024-02-15 16:11:06 +01:00
|
|
|
actions: write
|
2023-02-03 07:05:11 +01:00
|
|
|
outputs:
|
2024-02-14 09:25:33 +01:00
|
|
|
platforms: ${{ steps.platform_list.outputs.list }}
|
2024-02-15 12:01:02 +01:00
|
|
|
database: ${{ steps.database.outputs.list }}
|
2023-02-03 07:05:11 +01:00
|
|
|
components: ${{ steps.components.outputs.list }}
|
|
|
|
is_default_branch: ${{ steps.branch_info.outputs.is_default_branch }}
|
|
|
|
current_branch: ${{ steps.branch_info.outputs.current_branch }}
|
|
|
|
sha_short: ${{ steps.branch_info.outputs.sha_short }}
|
2024-02-14 09:25:33 +01:00
|
|
|
secret_prefix: ${{ steps.branch_info.outputs.secret_prefix }}
|
2023-02-03 07:05:11 +01:00
|
|
|
steps:
|
2024-02-11 09:12:08 +01:00
|
|
|
- name: Block egress traffic
|
|
|
|
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
|
|
|
|
with:
|
|
|
|
disable-sudo: true
|
|
|
|
egress-policy: block
|
|
|
|
allowed-endpoints: >
|
2024-02-15 15:49:11 +01:00
|
|
|
api.github.com:443
|
2024-02-11 09:12:08 +01:00
|
|
|
github.com:443
|
2024-02-15 15:50:26 +01:00
|
|
|
objects.githubusercontent.com:443
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
- name: Checkout repository
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2023-02-03 07:05:11 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
2024-02-15 13:16:24 +01:00
|
|
|
sparse-checkout: ${{ env.MATRIX_FILE }}
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-14 09:25:33 +01:00
|
|
|
- name: Check ${{ env.MATRIX_FILE }} file
|
|
|
|
id: build_exists
|
|
|
|
env:
|
|
|
|
MATRIX_FILE: ${{ env.MATRIX_FILE }}
|
|
|
|
run: |
|
|
|
|
if [[ ! -f "$MATRIX_FILE" ]]; then
|
|
|
|
echo "::error::File $MATRIX_FILE is missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Prepare Platform list
|
|
|
|
id: platform_list
|
|
|
|
env:
|
|
|
|
MATRIX_FILE: ${{ env.MATRIX_FILE }}
|
|
|
|
run: |
|
|
|
|
platform_list=$(jq -r '.["os-linux"].rhel | @json' "$MATRIX_FILE")
|
|
|
|
|
|
|
|
echo "::group::Platform List"
|
|
|
|
echo "$platform_list"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "list=$platform_list" >> $GITHUB_OUTPUT
|
|
|
|
|
2024-02-15 12:01:02 +01:00
|
|
|
- name: Prepare Database engine list
|
|
|
|
id: database
|
|
|
|
env:
|
|
|
|
MATRIX_FILE: ${{ env.MATRIX_FILE }}
|
|
|
|
run: |
|
|
|
|
database_list=$(jq -r '[.components | map_values(select(.rhel == true)) | values[].base ] | sort | unique | del(.. | select ( . == "" ) ) | @json' "$MATRIX_FILE")
|
|
|
|
|
|
|
|
echo "::group::Database List"
|
|
|
|
echo "$database_list"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "list=$database_list" >> $GITHUB_OUTPUT
|
|
|
|
|
2024-02-14 09:25:33 +01:00
|
|
|
- name: Prepare Zabbix component list
|
|
|
|
id: components
|
|
|
|
env:
|
|
|
|
MATRIX_FILE: ${{ env.MATRIX_FILE }}
|
|
|
|
run: |
|
2024-02-15 12:44:57 +01:00
|
|
|
component_list=$(jq -r '.components | map_values(select(.rhel == true)) | keys | @json' "$MATRIX_FILE")
|
2024-02-14 09:25:33 +01:00
|
|
|
|
|
|
|
echo "::group::Zabbix Component List"
|
|
|
|
echo "$component_list"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "list=$component_list" >> $GITHUB_OUTPUT
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
- name: Get branch info
|
|
|
|
id: branch_info
|
2024-02-11 09:12:08 +01:00
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
LATEST_BRANCH: ${{ env.LATEST_BRANCH }}
|
2024-02-11 10:07:29 +01:00
|
|
|
github_ref: ${{ github.ref }}
|
2024-05-08 09:05:28 +02:00
|
|
|
TRUNK_MAJOR_VERSION: ${{ inputs.trunk_version }}
|
2023-02-03 07:05:11 +01:00
|
|
|
run: |
|
|
|
|
result=false
|
2024-02-11 09:12:08 +01:00
|
|
|
sha_short=$(git rev-parse --short HEAD)
|
2023-02-03 07:05:11 +01:00
|
|
|
|
|
|
|
if [[ "$github_ref" == "refs/tags/"* ]]; then
|
|
|
|
github_ref=${github_ref%.*}
|
|
|
|
fi
|
|
|
|
|
|
|
|
github_ref=${github_ref##*/}
|
|
|
|
|
2024-02-11 09:12:08 +01:00
|
|
|
if [[ "$github_ref" == "$LATEST_BRANCH" ]]; then
|
|
|
|
result=true
|
|
|
|
fi
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "::group::Branch metadata"
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "is_default_branch - $result"
|
|
|
|
echo "current_branch - $github_ref"
|
2024-05-08 09:05:28 +02:00
|
|
|
if [ "${github_ref//.}" == "trunk" ] && [ ! -z "$TRUNK_MAJOR_VERSION" ]; then
|
|
|
|
echo "secret_prefix=RHEL_${TRUNK_MAJOR_VERSION//.}"
|
|
|
|
else
|
|
|
|
echo "secret_prefix=RHEL_${github_ref//.}"
|
|
|
|
fi
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "sha_short - $sha_short"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
echo "is_default_branch=$result" >> $GITHUB_OUTPUT
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "current_branch=$github_ref" >> $GITHUB_OUTPUT
|
2024-05-08 09:05:28 +02:00
|
|
|
if [ "${github_ref//.}" == "trunk" ] && [ ! -z "$TRUNK_MAJOR_VERSION" ]; then
|
|
|
|
echo "secret_prefix=RHEL_${TRUNK_MAJOR_VERSION//.}" >> $GITHUB_OUTPUT
|
|
|
|
else
|
|
|
|
echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT
|
|
|
|
fi
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-19 06:57:53 +01:00
|
|
|
- name: Cleanup existing cache
|
2024-02-15 15:47:14 +01:00
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
REPO: ${{ github.repository }}
|
|
|
|
BRANCH: ${{ steps.branch_info.outputs.current_branch }}
|
|
|
|
GH_RUN_ID: ${{ github.run_id }}
|
|
|
|
run: |
|
|
|
|
gh extension install actions/gh-actions-cache
|
|
|
|
|
|
|
|
cache_keys=$(gh actions-cache list -R "${REPO}" -B "${BRANCH}" -L 100 --sort created-at --order desc | cut -f 1)
|
|
|
|
|
|
|
|
## Setting this to not fail the workflow while deleting cache keys
|
|
|
|
set +e
|
|
|
|
echo "Deleting caches..."
|
|
|
|
for cache_key in $cache_keys
|
|
|
|
do
|
|
|
|
if [[ "$cache_key" == *"${GH_RUN_ID}" ]]; then
|
|
|
|
gh actions-cache delete $cache_key -R "${REPO}" -B "${BRANCH}" --confirm
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
build_base:
|
|
|
|
timeout-minutes: 30
|
2024-02-11 09:12:08 +01:00
|
|
|
name: Build ${{ matrix.build }} base (${{ matrix.arch }})
|
2023-02-03 07:05:11 +01:00
|
|
|
needs: ["init_build"]
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2024-02-11 09:12:08 +01:00
|
|
|
build: [build-base]
|
2024-02-14 09:25:33 +01:00
|
|
|
arch: ${{ fromJson(needs.init_build.outputs.platforms) }}
|
2024-02-11 09:12:08 +01:00
|
|
|
runs-on: [self-hosted, linux, "${{ matrix.arch }}"]
|
|
|
|
permissions:
|
|
|
|
contents: read
|
2023-02-03 07:05:11 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2023-02-03 07:05:11 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
2024-02-11 09:12:08 +01:00
|
|
|
- name: Install cosign
|
2024-02-19 06:57:53 +01:00
|
|
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
2024-02-11 09:12:08 +01:00
|
|
|
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4
|
|
|
|
with:
|
|
|
|
cosign-release: 'v2.2.3'
|
|
|
|
|
|
|
|
- name: Check cosign version
|
2024-02-19 06:57:53 +01:00
|
|
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
2024-02-11 09:12:08 +01:00
|
|
|
run: cosign version
|
|
|
|
|
|
|
|
- name: Fix string case
|
|
|
|
id: lc
|
|
|
|
env:
|
|
|
|
ARCH: ${{ matrix.arch }}
|
|
|
|
run: |
|
|
|
|
echo "arch=${ARCH,,}" >> $GITHUB_OUTPUT
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
- name: Generate tags
|
|
|
|
id: meta
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
2023-02-03 07:05:11 +01:00
|
|
|
with:
|
2024-02-11 09:12:08 +01:00
|
|
|
images: ${{ env.IMAGES_PREFIX }}${{ matrix.build }}
|
2023-02-03 07:05:11 +01:00
|
|
|
tags: |
|
2024-02-11 09:12:08 +01:00
|
|
|
type=sha,suffix=-${{ steps.lc.outputs.arch }}
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Build image
|
2023-02-03 07:05:11 +01:00
|
|
|
id: build_image
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
|
2023-02-03 07:05:11 +01:00
|
|
|
with:
|
2024-02-19 06:57:53 +01:00
|
|
|
context: ${{ format('{0}/{1}/rhel', env.DOCKERFILES_DIRECTORY, matrix.build) }}
|
2023-02-03 07:05:11 +01:00
|
|
|
layers: false
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
containerfiles: |
|
2024-02-11 09:12:08 +01:00
|
|
|
${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel/Dockerfile
|
2023-02-03 07:05:11 +01:00
|
|
|
extra-args: |
|
|
|
|
--pull
|
2024-02-15 10:44:40 +01:00
|
|
|
--iidfile=${{ github.workspace }}/iidfile
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-19 06:57:53 +01:00
|
|
|
- name: Image metadata
|
2024-02-15 11:26:23 +01:00
|
|
|
id: image_metadata
|
2024-02-11 09:12:08 +01:00
|
|
|
env:
|
2024-02-14 18:56:07 +01:00
|
|
|
IMAGE_TAG: ${{ steps.build_image.outputs.image-with-tag }}
|
2024-02-11 09:12:08 +01:00
|
|
|
CACHE_FILE_NAME: ${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}
|
2024-02-15 10:40:07 +01:00
|
|
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
2024-02-11 09:12:08 +01:00
|
|
|
run: |
|
2024-02-15 10:34:47 +01:00
|
|
|
TAG_ID=$(cat $GITHUB_WORKSPACE/iidfile)
|
2024-02-15 10:00:29 +01:00
|
|
|
|
2024-02-14 18:56:07 +01:00
|
|
|
echo "::group::Image tag"
|
|
|
|
echo "image_tag=$IMAGE_TAG"
|
|
|
|
echo "::endgroup::"
|
2024-02-15 10:23:19 +01:00
|
|
|
echo "::group::Image Tag ID"
|
|
|
|
echo "tag_id=$TAG_ID"
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::Cache file name"
|
|
|
|
echo "$CACHE_FILE_NAME"
|
|
|
|
echo "::endgroup::"
|
2024-02-14 18:56:07 +01:00
|
|
|
|
2024-02-14 19:39:17 +01:00
|
|
|
echo "$TAG_ID" > "${CACHE_FILE_NAME}_tag_id"
|
2024-02-14 18:56:07 +01:00
|
|
|
echo "$IMAGE_TAG" > "${CACHE_FILE_NAME}_tag"
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
echo "image_tag_id=${TAG_ID}" >> $GITHUB_OUTPUT
|
|
|
|
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Cache image metadata
|
2024-02-14 20:54:44 +01:00
|
|
|
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
2024-02-11 09:12:08 +01:00
|
|
|
with:
|
2024-02-14 18:56:07 +01:00
|
|
|
path: |
|
2024-02-14 19:39:17 +01:00
|
|
|
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag_id
|
2024-02-14 18:56:07 +01:00
|
|
|
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag
|
2024-02-15 10:25:42 +01:00
|
|
|
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.arch }}-${{ github.run_id }}
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-14 19:06:48 +01:00
|
|
|
- name: Push image to local storage
|
2024-02-15 16:32:23 +01:00
|
|
|
id: push_image
|
2024-02-14 18:56:07 +01:00
|
|
|
env:
|
2024-02-15 11:26:23 +01:00
|
|
|
IMAGE_TAG: ${{ steps.image_metadata.outputs.image_tag }}
|
|
|
|
IMAGE_TAG_ID: ${{ steps.image_metadata.outputs.image_tag_id }}
|
2024-02-14 19:39:17 +01:00
|
|
|
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
2024-02-14 18:56:07 +01:00
|
|
|
run: |
|
|
|
|
echo "::group::Result"
|
2024-02-15 13:42:58 +01:00
|
|
|
echo "Image ${IMAGE_TAG} location: \"${IMAGE_DIR}/${IMAGE_TAG_ID}\""
|
2024-02-15 11:26:23 +01:00
|
|
|
podman push "${IMAGE_TAG}" dir:"${IMAGE_DIR}/${IMAGE_TAG_ID}"
|
2024-02-14 18:56:07 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-14 19:39:17 +01:00
|
|
|
- name: Post build image
|
2024-02-15 10:26:43 +01:00
|
|
|
if: ${{ success() || failure() }}
|
2024-02-14 19:06:48 +01:00
|
|
|
env:
|
2024-02-15 12:44:57 +01:00
|
|
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
2024-02-14 19:06:48 +01:00
|
|
|
run: |
|
|
|
|
echo "::group::Result"
|
2024-02-15 10:44:40 +01:00
|
|
|
|
|
|
|
rm -rf "$GITHUB_WORKSPACE/iidfile"
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "Removing working containers"
|
|
|
|
buildah rm -a 2>/dev/null || true
|
|
|
|
echo "Removing container data in storage not controlled by podman"
|
|
|
|
podman system prune --external 2>/dev/null
|
|
|
|
echo "Removing all unused container data with volumes"
|
|
|
|
podman system prune -a --volumes -f 2>/dev/null
|
|
|
|
echo "Reseting podman storage to default state"
|
2024-02-14 21:38:36 +01:00
|
|
|
podman system reset -f 2>/dev/null || true
|
2024-02-15 10:44:40 +01:00
|
|
|
|
2024-02-14 19:06:48 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-15 18:07:02 +01:00
|
|
|
- name: Check on failures
|
2024-02-15 16:32:23 +01:00
|
|
|
if: ${{ (cancelled() || failure()) && ( steps.push_image.outcome == 'failure' || steps.push_image.outcome == 'cancelled') }}
|
|
|
|
env:
|
|
|
|
IMAGE_TAG_ID: ${{ steps.image_metadata.outputs.image_tag_id }}
|
2024-02-19 06:57:53 +01:00
|
|
|
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
2024-02-15 16:32:23 +01:00
|
|
|
run: |
|
|
|
|
echo "::group::Removing orphaned image"
|
|
|
|
rm -rf "${IMAGE_DIR}/${IMAGE_TAG_ID}"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
build_base_database:
|
2024-02-19 06:57:53 +01:00
|
|
|
timeout-minutes: 90
|
2023-02-03 07:05:11 +01:00
|
|
|
needs: [ "build_base", "init_build"]
|
2024-02-11 09:12:08 +01:00
|
|
|
name: Build ${{ matrix.build }} base (${{ matrix.arch }})
|
2023-02-03 07:05:11 +01:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2024-02-15 12:01:02 +01:00
|
|
|
build: ${{ fromJson(needs.init_build.outputs.database) }}
|
2024-02-14 09:25:33 +01:00
|
|
|
arch: ${{ fromJson(needs.init_build.outputs.platforms) }}
|
2024-02-11 09:12:08 +01:00
|
|
|
runs-on: [self-hosted, linux, "${{ matrix.arch }}"]
|
|
|
|
permissions:
|
|
|
|
contents: read
|
2023-02-03 07:05:11 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2023-02-03 07:05:11 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
2024-02-11 09:12:08 +01:00
|
|
|
- name: Fix string case
|
|
|
|
id: lc
|
|
|
|
env:
|
|
|
|
ARCH: ${{ matrix.arch }}
|
|
|
|
run: |
|
|
|
|
echo "arch=${ARCH,,}" >> $GITHUB_OUTPUT
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Download metadata of ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }}
|
2024-02-14 20:54:44 +01:00
|
|
|
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
2024-02-11 09:12:08 +01:00
|
|
|
with:
|
2024-02-14 18:56:07 +01:00
|
|
|
path: |
|
2024-02-14 19:39:17 +01:00
|
|
|
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag_id
|
2024-02-14 18:56:07 +01:00
|
|
|
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag
|
2024-02-15 10:25:42 +01:00
|
|
|
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.arch }}-${{ github.run_id }}
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-19 06:57:53 +01:00
|
|
|
- name: Pull ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }} image from local storage
|
2024-02-15 11:03:48 +01:00
|
|
|
id: base_build
|
2024-02-14 18:56:07 +01:00
|
|
|
env:
|
|
|
|
MATRIX_ARCH: ${{ matrix.arch }}
|
|
|
|
BASE_IMAGE: ${{ env.BASE_BUILD_NAME }}
|
|
|
|
IMAGES_PREFIX: ${{ env.IMAGES_PREFIX }}
|
|
|
|
run: |
|
2024-02-15 10:23:19 +01:00
|
|
|
BASE_TAG_ID=$(cat "${BASE_IMAGE}_${MATRIX_ARCH}_tag_id")
|
2024-02-15 11:03:48 +01:00
|
|
|
BASE_IMAGE_TAG=$(cat "${BASE_IMAGE}_${MATRIX_ARCH}_tag")
|
2024-02-14 18:56:07 +01:00
|
|
|
|
|
|
|
echo "::group::Pull image"
|
2024-02-15 10:23:19 +01:00
|
|
|
echo "podman pull dir:\"${IMAGE_DIR}/${BASE_TAG_ID}\""
|
|
|
|
podman pull dir:"${IMAGE_DIR}/${BASE_TAG_ID}"
|
2024-02-14 18:56:07 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-15 11:03:48 +01:00
|
|
|
echo "::group::Tag image"
|
|
|
|
echo "podman tag \"${BASE_TAG_ID}\" \"${BASE_IMAGE_TAG}\""
|
|
|
|
podman tag "${BASE_TAG_ID}" "${BASE_IMAGE_TAG}"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::SHA256 tag"
|
|
|
|
DIGEST=$(podman inspect "${BASE_TAG_ID}" --format '{{ .Digest }}')
|
|
|
|
BASE_BUILD_IMAGE="${IMAGES_PREFIX}${BASE_IMAGE}@${DIGEST}"
|
2024-02-15 14:15:47 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "base_build_image=${BASE_BUILD_IMAGE}"
|
2024-02-15 11:03:48 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "base_build_image=${BASE_BUILD_IMAGE}" >> $GITHUB_OUTPUT
|
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
- name: Generate tags
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
|
|
|
with:
|
|
|
|
images: ${{ env.IMAGES_PREFIX }}${{ matrix.build }}
|
|
|
|
tags: |
|
|
|
|
type=sha,suffix=-${{ steps.lc.outputs.arch }}
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Build image
|
2023-02-03 07:05:11 +01:00
|
|
|
id: build_image
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
|
2023-02-03 07:05:11 +01:00
|
|
|
with:
|
2024-02-19 06:57:53 +01:00
|
|
|
context: ${{ format('{0}/{1}/rhel', env.DOCKERFILES_DIRECTORY, matrix.build) }}
|
2023-02-03 07:05:11 +01:00
|
|
|
layers: false
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
containerfiles: |
|
2024-02-11 09:12:08 +01:00
|
|
|
${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel/Dockerfile
|
|
|
|
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
2024-02-15 11:26:23 +01:00
|
|
|
extra-args: |
|
|
|
|
--iidfile=${{ github.workspace }}/iidfile
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
- name: Prepare image metadata
|
|
|
|
id: image_metadata
|
2024-02-11 09:12:08 +01:00
|
|
|
env:
|
2024-02-14 19:39:17 +01:00
|
|
|
IMAGE_TAG: ${{ steps.build_image.outputs.image-with-tag }}
|
2024-02-11 09:12:08 +01:00
|
|
|
CACHE_FILE_NAME: ${{ matrix.build }}_${{ matrix.arch }}
|
2024-02-15 11:26:23 +01:00
|
|
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
2024-02-11 09:12:08 +01:00
|
|
|
run: |
|
2024-02-15 11:26:23 +01:00
|
|
|
TAG_ID=$(cat $GITHUB_WORKSPACE/iidfile)
|
2024-02-14 19:39:17 +01:00
|
|
|
|
|
|
|
echo "::group::Image tag"
|
|
|
|
echo "image_tag=$IMAGE_TAG"
|
|
|
|
echo "::endgroup::"
|
2024-02-15 11:26:23 +01:00
|
|
|
echo "::group::Image Tag ID"
|
|
|
|
echo "tag_id=$TAG_ID"
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::Cache file name"
|
|
|
|
echo "$CACHE_FILE_NAME"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-14 19:39:17 +01:00
|
|
|
echo "$TAG_ID" > "${CACHE_FILE_NAME}_tag_id"
|
|
|
|
echo "$IMAGE_TAG" > "${CACHE_FILE_NAME}_tag"
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
echo "image_tag_id=${TAG_ID}" >> $GITHUB_OUTPUT
|
|
|
|
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
|
|
|
|
2024-02-19 06:57:53 +01:00
|
|
|
- name: Cache image metadata
|
2024-02-14 20:54:44 +01:00
|
|
|
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
2024-02-11 09:12:08 +01:00
|
|
|
with:
|
2024-02-14 19:39:17 +01:00
|
|
|
path: |
|
|
|
|
${{ matrix.build }}_${{ matrix.arch }}_tag_id
|
|
|
|
${{ matrix.build }}_${{ matrix.arch }}_tag
|
2024-02-15 10:25:42 +01:00
|
|
|
key: ${{ matrix.build }}-${{ matrix.arch }}-${{ github.run_id }}
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-14 19:39:17 +01:00
|
|
|
- name: Push image to local storage
|
2024-02-15 16:32:23 +01:00
|
|
|
id: push_image
|
2024-02-14 19:39:17 +01:00
|
|
|
env:
|
2024-02-15 11:26:23 +01:00
|
|
|
IMAGE_TAG: ${{ steps.image_metadata.outputs.image_tag }}
|
|
|
|
IMAGE_TAG_ID: ${{ steps.image_metadata.outputs.image_tag_id }}
|
2024-02-14 19:39:17 +01:00
|
|
|
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
|
|
|
run: |
|
|
|
|
echo "::group::Result"
|
2024-02-15 11:26:23 +01:00
|
|
|
echo "podman push \"${IMAGE_TAG}\" dir:\"${IMAGE_DIR}/${IMAGE_TAG_ID}\""
|
|
|
|
podman push "${IMAGE_TAG}" dir:"${IMAGE_DIR}/${IMAGE_TAG_ID}"
|
2024-02-14 19:39:17 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
- name: Post build image
|
2024-02-15 10:26:43 +01:00
|
|
|
if: ${{ success() || failure() }}
|
2024-02-14 19:39:17 +01:00
|
|
|
env:
|
2024-02-15 12:44:57 +01:00
|
|
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
2024-02-14 19:39:17 +01:00
|
|
|
run: |
|
|
|
|
echo "::group::Result"
|
2024-02-15 11:26:23 +01:00
|
|
|
|
|
|
|
rm -rf "$GITHUB_WORKSPACE/iidfile"
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "Removing working containers"
|
|
|
|
buildah rm -a 2>/dev/null || true
|
|
|
|
echo "Removing container data in storage not controlled by podman"
|
|
|
|
podman system prune --external 2>/dev/null
|
|
|
|
echo "Removing all unused container data with volumes"
|
|
|
|
podman system prune -a --volumes -f 2>/dev/null
|
|
|
|
echo "Reseting podman storage to default state"
|
2024-02-14 21:38:36 +01:00
|
|
|
podman system reset -f 2>/dev/null || true
|
2024-02-15 11:26:23 +01:00
|
|
|
|
2024-02-14 19:39:17 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-15 18:07:02 +01:00
|
|
|
- name: Check on failures
|
2024-02-15 16:32:23 +01:00
|
|
|
if: ${{ (cancelled() || failure()) && ( steps.push_image.outcome == 'failure' || steps.push_image.outcome == 'cancelled') }}
|
|
|
|
env:
|
|
|
|
IMAGE_TAG_ID: ${{ steps.image_metadata.outputs.image_tag_id }}
|
2024-02-19 06:57:53 +01:00
|
|
|
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
2024-02-15 16:32:23 +01:00
|
|
|
run: |
|
|
|
|
echo "::group::Removing orphaned image"
|
|
|
|
rm -rf "${IMAGE_DIR}/${IMAGE_TAG_ID}"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
2023-02-03 07:05:11 +01:00
|
|
|
build_images:
|
2024-02-19 06:57:53 +01:00
|
|
|
timeout-minutes: 30
|
2023-02-03 07:05:11 +01:00
|
|
|
needs: [ "build_base_database", "init_build"]
|
2024-02-11 09:12:08 +01:00
|
|
|
name: Build ${{ matrix.build }} image (${{ matrix.arch }})
|
2023-02-03 07:05:11 +01:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
build: ${{ fromJson(needs.init_build.outputs.components) }}
|
2024-02-14 09:25:33 +01:00
|
|
|
arch: ${{ fromJson(needs.init_build.outputs.platforms) }}
|
2024-02-11 09:12:08 +01:00
|
|
|
runs-on: [self-hosted, linux, "${{ matrix.arch }}"]
|
|
|
|
permissions:
|
|
|
|
contents: read
|
2023-02-03 07:05:11 +01:00
|
|
|
steps:
|
2024-02-11 09:12:08 +01:00
|
|
|
- name: Checkout repository
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2024-02-11 09:12:08 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
2024-02-14 09:25:33 +01:00
|
|
|
- name: Variables formating
|
|
|
|
id: var_format
|
2024-02-11 09:12:08 +01:00
|
|
|
env:
|
2024-02-14 09:25:33 +01:00
|
|
|
MATRIX_BUILD: ${{ matrix.build }}
|
2024-02-11 09:12:08 +01:00
|
|
|
run: |
|
2024-02-14 09:25:33 +01:00
|
|
|
MATRIX_BUILD=${MATRIX_BUILD^^}
|
|
|
|
MATRIX_BUILD=${MATRIX_BUILD//-/_}
|
2024-02-15 12:44:57 +01:00
|
|
|
|
2024-02-14 09:25:33 +01:00
|
|
|
echo "::group::Result"
|
|
|
|
echo "matrix_build=${MATRIX_BUILD}"
|
|
|
|
echo "::endgroup::"
|
|
|
|
echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT
|
2023-02-03 07:05:11 +01:00
|
|
|
|
|
|
|
- name: Detect Build Base Image
|
|
|
|
id: build_base_image
|
2024-02-15 12:01:02 +01:00
|
|
|
if: ${{ matrix.build != 'snmptraps' }}
|
2023-02-03 07:05:11 +01:00
|
|
|
env:
|
2024-02-11 09:12:08 +01:00
|
|
|
MATRIX_BUILD: ${{ matrix.build }}
|
2024-02-14 09:25:33 +01:00
|
|
|
MATRIX_FILE: ${{ env.MATRIX_FILE }}
|
2023-02-03 07:05:11 +01:00
|
|
|
run: |
|
2024-02-14 09:25:33 +01:00
|
|
|
BUILD_BASE=$(jq -r ".components.\"$MATRIX_BUILD\".base" "$MATRIX_FILE")
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-14 09:25:33 +01:00
|
|
|
echo "::group::Base Build Image"
|
|
|
|
echo "$BUILD_BASE"
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "::endgroup::"
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-14 09:25:33 +01:00
|
|
|
echo "build_base=${BUILD_BASE}" >> $GITHUB_OUTPUT
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Download metadata of ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.arch }}
|
2024-02-14 09:25:33 +01:00
|
|
|
if: ${{ matrix.build != 'snmptraps' }}
|
2024-02-14 20:54:44 +01:00
|
|
|
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
2024-02-11 09:12:08 +01:00
|
|
|
with:
|
2024-02-14 19:39:17 +01:00
|
|
|
path: |
|
|
|
|
${{ steps.build_base_image.outputs.build_base }}_${{ matrix.arch }}_tag_id
|
|
|
|
${{ steps.build_base_image.outputs.build_base }}_${{ matrix.arch }}_tag
|
2024-02-15 10:25:42 +01:00
|
|
|
key: ${{ steps.build_base_image.outputs.build_base }}-${{ matrix.arch }}-${{ github.run_id }}
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
- name: Pull ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.arch }} image
|
2024-02-11 09:12:08 +01:00
|
|
|
id: base_build
|
2024-02-15 12:01:02 +01:00
|
|
|
if: ${{ matrix.build != 'snmptraps' }}
|
2024-02-11 09:12:08 +01:00
|
|
|
env:
|
|
|
|
MATRIX_ARCH: ${{ matrix.arch }}
|
|
|
|
BASE_IMAGE: ${{ steps.build_base_image.outputs.build_base }}
|
|
|
|
IMAGES_PREFIX: ${{ env.IMAGES_PREFIX }}
|
|
|
|
run: |
|
2024-02-15 11:26:23 +01:00
|
|
|
BASE_TAG_ID=$(cat "${BASE_IMAGE}_${MATRIX_ARCH}_tag_id")
|
|
|
|
BASE_IMAGE_TAG=$(cat "${BASE_IMAGE}_${MATRIX_ARCH}_tag")
|
|
|
|
|
|
|
|
echo "::group::Pull image"
|
|
|
|
echo "podman pull dir:\"${IMAGE_DIR}/${BASE_TAG_ID}\""
|
|
|
|
podman pull dir:"${IMAGE_DIR}/${BASE_TAG_ID}"
|
|
|
|
echo "::endgroup::"
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
echo "::group::Tag image"
|
|
|
|
echo "podman tag \"${BASE_TAG_ID}\" \"${BASE_IMAGE_TAG}\""
|
|
|
|
podman tag "${BASE_TAG_ID}" "${BASE_IMAGE_TAG}"
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
echo "::group::SHA256 tag"
|
|
|
|
DIGEST=$(podman inspect "${BASE_TAG_ID}" --format '{{ .Digest }}')
|
|
|
|
BASE_BUILD_IMAGE="${IMAGES_PREFIX}${BASE_IMAGE}@${DIGEST}"
|
|
|
|
echo "digest=${BASE_BUILD_IMAGE}"
|
|
|
|
echo "::endgroup::"
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
echo "base_build_image=${BASE_BUILD_IMAGE}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Remove smartmontools
|
|
|
|
if: ${{ matrix.build == 'agent2' }}
|
2024-02-14 19:39:17 +01:00
|
|
|
env:
|
2024-02-15 11:26:23 +01:00
|
|
|
DOCKERFILES_DIRECTORY: ${{ env.DOCKERFILES_DIRECTORY }}
|
2024-02-14 19:39:17 +01:00
|
|
|
run: |
|
2024-02-15 11:26:23 +01:00
|
|
|
sed -i '/smartmontools/d' "$DOCKERFILES_DIRECTORY/agent2/rhel/Dockerfile"
|
2024-02-14 19:39:17 +01:00
|
|
|
|
2024-02-15 11:26:23 +01:00
|
|
|
- name: Generate tags
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/${{ secrets[format('{0}_{1}_PROJECT', needs.init_build.outputs.secret_prefix, steps.var_format.outputs.matrix_build)] || matrix.build }}
|
|
|
|
tags: |
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=sha
|
|
|
|
flavor: |
|
|
|
|
latest=${{ github.event_name == 'release' }}
|
|
|
|
suffix=${{ matrix.arch == 'ARM64' && '-arm64' || '' }},onlatest=true
|
2024-02-14 19:39:17 +01:00
|
|
|
|
2024-02-14 11:02:56 +01:00
|
|
|
- name: Build image
|
2023-02-03 07:05:11 +01:00
|
|
|
id: build_image
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
|
2023-02-03 07:05:11 +01:00
|
|
|
with:
|
2024-02-19 06:57:53 +01:00
|
|
|
context: ${{ format('{0}/{1}/rhel', env.DOCKERFILES_DIRECTORY, matrix.build) }}
|
2023-02-03 07:05:11 +01:00
|
|
|
layers: false
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.revision=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
|
|
|
org.opencontainers.image.created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
|
|
|
containerfiles: |
|
2024-02-11 09:12:08 +01:00
|
|
|
${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel/Dockerfile
|
2024-02-18 16:04:01 +01:00
|
|
|
extra-args: |
|
|
|
|
--pull
|
|
|
|
--iidfile=${{ github.workspace }}/iidfile
|
2024-02-11 09:12:08 +01:00
|
|
|
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Log in to ${{ env.REGISTRY }}
|
2024-02-14 11:02:56 +01:00
|
|
|
uses: redhat-actions/podman-login@9184318aae1ee5034fbfbacc0388acf12669171f # v1.6
|
|
|
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
|
|
|
with:
|
|
|
|
username: ${{ format('redhat-isv-containers+{0}-robot', secrets[format('{0}_{1}_PROJECT', needs.init_build.outputs.secret_prefix, steps.var_format.outputs.matrix_build)]) }}
|
|
|
|
password: ${{ secrets[format('{0}_{1}_SECRET', needs.init_build.outputs.secret_prefix, steps.var_format.outputs.matrix_build)] }}
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
auth_file_path: /tmp/.docker_${{ matrix.build }}_${{ matrix.arch }}_${{ needs.init_build.outputs.sha_short }}
|
|
|
|
|
|
|
|
- name: Push to RedHat certification procedure (1st)
|
2023-02-03 07:05:11 +01:00
|
|
|
id: push_to_registry
|
2024-02-11 09:12:08 +01:00
|
|
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: redhat-actions/push-to-registry@9986a6552bc4571882a4a67e016b17361412b4df # v2.7.1
|
2023-02-03 07:05:11 +01:00
|
|
|
with:
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Preflight certification
|
2024-02-11 09:12:08 +01:00
|
|
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
2023-02-03 07:05:11 +01:00
|
|
|
env:
|
2024-02-11 09:12:08 +01:00
|
|
|
PFLT_DOCKERCONFIG: /tmp/.docker_${{ matrix.build }}_${{ matrix.arch }}_${{ needs.init_build.outputs.sha_short }}
|
2024-02-14 09:25:33 +01:00
|
|
|
PFLT_CERTIFICATION_PROJECT_ID: ${{ secrets[format('{0}_{1}_PROJECT', needs.init_build.outputs.secret_prefix, steps.var_format.outputs.matrix_build)] }}
|
2023-02-03 07:05:11 +01:00
|
|
|
PFLT_PYXIS_API_TOKEN: ${{ secrets.REDHAT_API_TOKEN }}
|
|
|
|
PFLT_ARTIFACTS: ${{ env.PFLT_ARTIFACTS }}
|
|
|
|
PFLT_LOGLEVEL: ${{ env.PFLT_LOGLEVEL }}
|
2024-02-11 09:12:08 +01:00
|
|
|
IMAGE_TAG: ${{ steps.build_image.outputs.image-with-tag }}
|
|
|
|
PREFLIGHT_IMAGE: ${{ env.PREFLIGHT_IMAGE }}
|
2023-02-03 07:05:11 +01:00
|
|
|
run: |
|
2024-02-11 09:12:08 +01:00
|
|
|
mkdir -p $PFLT_ARTIFACTS
|
2024-02-15 11:26:23 +01:00
|
|
|
echo "::group::Pull preflight \"$PREFLIGHT_IMAGE\" image"
|
2024-02-11 09:12:08 +01:00
|
|
|
podman pull "$PREFLIGHT_IMAGE"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::Perform certification tests"
|
|
|
|
podman run \
|
2023-02-03 07:05:11 +01:00
|
|
|
-it \
|
|
|
|
--rm \
|
|
|
|
--security-opt=label=disable \
|
|
|
|
--env PFLT_LOGLEVEL=$PFLT_LOGLEVEL \
|
|
|
|
--env PFLT_ARTIFACTS=/artifacts \
|
|
|
|
--env PFLT_LOGFILE=/artifacts/preflight.log \
|
|
|
|
--env PFLT_CERTIFICATION_PROJECT_ID=$PFLT_CERTIFICATION_PROJECT_ID \
|
|
|
|
--env PFLT_PYXIS_API_TOKEN=$PFLT_PYXIS_API_TOKEN \
|
|
|
|
--env PFLT_DOCKERCONFIG=/temp-authfile.json \
|
|
|
|
-v $PFLT_ARTIFACTS:/artifacts \
|
|
|
|
-v $PFLT_DOCKERCONFIG:/temp-authfile.json:ro \
|
2024-02-11 09:12:08 +01:00
|
|
|
"$PREFLIGHT_IMAGE" check container $IMAGE_TAG --submit
|
|
|
|
podman rmi -i -f "$PREFLIGHT_IMAGE"
|
|
|
|
echo "::endgroup::"
|
2023-02-03 07:05:11 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Push to RedHat certification procedure (all tags)
|
2023-02-05 09:17:09 +01:00
|
|
|
id: push_to_registry_all_tags
|
2024-02-11 09:12:08 +01:00
|
|
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
2024-02-11 17:44:17 +01:00
|
|
|
uses: redhat-actions/push-to-registry@9986a6552bc4571882a4a67e016b17361412b4df # v2.7.1
|
2023-02-05 09:17:09 +01:00
|
|
|
with:
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Post Preflight certification
|
|
|
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' && (success() || failure()) }}
|
2024-02-11 09:12:08 +01:00
|
|
|
env:
|
2024-02-14 21:16:11 +01:00
|
|
|
PREFLIGHT_IMAGE: ${{ env.PREFLIGHT_IMAGE }}
|
|
|
|
PFLT_ARTIFACTS: ${{ env.PFLT_ARTIFACTS }}
|
2023-02-03 07:05:11 +01:00
|
|
|
run: |
|
2024-02-14 20:54:44 +01:00
|
|
|
echo "::group::Result"
|
2024-02-14 21:16:11 +01:00
|
|
|
rm -rf "$PFLT_ARTIFACTS"
|
|
|
|
podman rmi -i -f "$PREFLIGHT_IMAGE"
|
2024-02-14 20:54:44 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-18 16:04:01 +01:00
|
|
|
- name: Image digest
|
|
|
|
env:
|
|
|
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
|
|
|
run: |
|
|
|
|
TAG_ID=$(cat $GITHUB_WORKSPACE/iidfile)
|
|
|
|
echo "::group::Image digest"
|
|
|
|
echo "$TAG_ID"
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-14 21:16:11 +01:00
|
|
|
- name: Post build image
|
2024-02-15 10:26:43 +01:00
|
|
|
if: ${{ success() || failure() }}
|
2024-02-19 06:57:53 +01:00
|
|
|
env:
|
|
|
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
2024-02-14 20:54:44 +01:00
|
|
|
run: |
|
|
|
|
echo "::group::Result"
|
2024-02-15 11:26:23 +01:00
|
|
|
|
2024-02-19 06:57:53 +01:00
|
|
|
rm -rf "$GITHUB_WORKSPACE/iidfile"
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "Removing working containers"
|
|
|
|
buildah rm -a 2>/dev/null || true
|
|
|
|
echo "Removing container data in storage not controlled by podman"
|
|
|
|
podman system prune --external 2>/dev/null
|
|
|
|
echo "Removing all unused container data with volumes"
|
|
|
|
podman system prune -a --volumes -f 2>/dev/null
|
|
|
|
echo "Reseting podman storage to default state"
|
2024-02-14 21:38:36 +01:00
|
|
|
podman system reset -f 2>/dev/null || true
|
2024-02-15 11:26:23 +01:00
|
|
|
|
2024-02-11 09:12:08 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
clear_artifacts:
|
2024-02-19 06:57:53 +01:00
|
|
|
timeout-minutes: 10
|
2024-02-15 12:01:59 +01:00
|
|
|
needs: [ "build_images", "init_build"]
|
2024-02-15 12:01:02 +01:00
|
|
|
name: Clear ${{ matrix.build }} image cache (${{ matrix.arch }})
|
2024-02-11 09:12:08 +01:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2024-02-15 12:01:59 +01:00
|
|
|
build: ${{ fromJson(needs.init_build.outputs.database) }}
|
2024-02-14 20:54:44 +01:00
|
|
|
arch: ${{ fromJson(needs.init_build.outputs.platforms) }}
|
2024-02-11 09:12:08 +01:00
|
|
|
runs-on: [self-hosted, linux, "${{ matrix.arch }}"]
|
2024-02-15 12:44:57 +01:00
|
|
|
if: ${{ needs.build_base_database.result == 'success' }}
|
2024-02-11 09:12:08 +01:00
|
|
|
permissions: {}
|
|
|
|
steps:
|
2024-02-15 12:44:57 +01:00
|
|
|
- name: Download metadata of ${{ matrix.build }}:${{ matrix.arch }}
|
2024-02-14 20:54:44 +01:00
|
|
|
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
2024-02-11 09:12:08 +01:00
|
|
|
with:
|
2024-02-15 10:00:29 +01:00
|
|
|
path: |
|
|
|
|
${{ matrix.build }}_${{ matrix.arch }}_tag_id
|
|
|
|
${{ matrix.build }}_${{ matrix.arch }}_tag
|
2024-02-15 10:25:42 +01:00
|
|
|
key: ${{ matrix.build }}-${{ matrix.arch }}-${{ github.run_id }}
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-14 20:00:03 +01:00
|
|
|
- name: Remove ${{ matrix.build }}:${{ matrix.arch }} cache
|
2024-02-11 09:12:08 +01:00
|
|
|
env:
|
2024-02-15 12:44:57 +01:00
|
|
|
CACHE_FILE_NAME: ${{ matrix.build }}_${{ matrix.arch }}
|
2024-02-14 20:00:03 +01:00
|
|
|
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
2024-02-11 09:12:08 +01:00
|
|
|
run: |
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "::group::Result"
|
2024-02-16 03:11:37 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
BASE_TAG=$(cat "${CACHE_FILE_NAME}_tag_id")
|
|
|
|
echo "Removing ${IMAGE_DIR}/${BASE_TAG}"
|
2024-02-14 20:00:03 +01:00
|
|
|
rm -rf "${IMAGE_DIR}/${BASE_TAG}"
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
- name: Download metadata of ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }}
|
2024-02-14 20:54:44 +01:00
|
|
|
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
2024-02-11 09:12:08 +01:00
|
|
|
with:
|
2024-02-15 12:44:57 +01:00
|
|
|
path: |
|
|
|
|
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag_id
|
|
|
|
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag
|
2024-02-15 10:25:42 +01:00
|
|
|
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.arch }}-${{ github.run_id }}
|
2024-02-11 09:12:08 +01:00
|
|
|
|
2024-02-14 20:00:03 +01:00
|
|
|
- name: Remove ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }} cache
|
2024-02-11 09:12:08 +01:00
|
|
|
env:
|
2024-02-15 12:44:57 +01:00
|
|
|
CACHE_FILE_NAME: ${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}
|
2024-02-14 20:00:03 +01:00
|
|
|
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
2024-02-11 09:12:08 +01:00
|
|
|
run: |
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "::group::Result"
|
2024-02-16 03:11:37 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
BASE_TAG=$(cat "${CACHE_FILE_NAME}_tag_id")
|
|
|
|
echo "Removing ${IMAGE_DIR}/${BASE_TAG}"
|
2024-02-14 20:54:44 +01:00
|
|
|
rm -rf "${IMAGE_DIR}/${BASE_TAG}"
|
2024-02-16 03:11:37 +01:00
|
|
|
|
2024-02-15 12:44:57 +01:00
|
|
|
echo "::endgroup::"
|