Skip to content

Merge pull request #3743 from ty-dc/fix/kubevirt-ci #5

Merge pull request #3743 from ty-dc/fix/kubevirt-ci

Merge pull request #3743 from ty-dc/fix/kubevirt-ci #5

name: Auto Build Image Plugins
# final packed image : ${ONLINE_REGISTER}/${IMAGE_REPO}/${IMAGE_NAME}:${inputs.tag}
# image dockerfile path on the repo: ${IMAGE_ROOT_PATH}/${IMAGE_NAME}/Dockerfile
env:
IMAGE_NAME: spiderpool-plugins
IMAGE_REPO: ${{ github.repository }}
ONLINE_REGISTER: ghcr.io
IMAGE_ROOT_PATH: images
BUILD_PLATFORM: linux/amd64,linux/arm64
ONLINE_REGISTER_USER: ${{ github.actor }}
ONLINE_REGISTER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKERFILE_DIR: images/spiderpool-plugins
on:
workflow_dispatch:
inputs:
ref:
description: 'sha, Tag'
required: true
default: main
push:
branches:
- main
paths:
- images/spiderpool-plugins/**
permissions: write-all
# concurrency:
# group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.sha }}
# cancel-in-progress: true
jobs:
build-and-push:
timeout-minutes: 30
environment: release-base-images
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Set up QEMU
id: qemu
uses: docker/[email protected]
- name: Get Info
id: get_info
continue-on-error: false
run: |
if ${{ github.event_name == 'workflow_dispatch' }}; then
echo "event_ref=${{ github.event.inputs.ref }}" >> $GITHUB_OUTPUT
elif ${{ github.event_name == 'push' }} ; then
echo "event_ref=${{ github.ref }}" >> $GITHUB_OUTPUT
else
echo "unexpected event"
exit 1
fi
- name: Checkout Source Code
uses: actions/checkout@v4
with:
persist-credentials: false
# fetch-depth: 0
ref: ${{ steps.get_info.outputs.event_ref }}
- name: Getting Build Arg
id: arg
run: |
GIT_COMMIT_HASH=$( git show -s --format='format:%H')
GIT_COMMIT_TIME=$( git show -s --format='format:%aI')
echo "commit_hash=${GIT_COMMIT_HASH}" >> $GITHUB_OUTPUT
echo "commit_time=${GIT_COMMIT_TIME}" >> $GITHUB_OUTPUT
echo "image_tag=$(git ls-tree --full-tree HEAD -- ${{ env.DOCKERFILE_DIR }} | awk '{ print $3 }')" >> $GITHUB_OUTPUT
echo ""
source ${{ env.DOCKERFILE_DIR }}/version.sh
echo "CNI_VERSION=${CNI_VERSION}" >> $GITHUB_OUTPUT
echo "OVS_VERSION=${OVS_VERSION}" >> $GITHUB_OUTPUT
echo "RDMA_VERSION=${RDMA_VERSION}" >> $GITHUB_OUTPUT
echo "SRIOV_VERSION=${SRIOV_VERSION}" >> $GITHUB_OUTPUT
echo "IB_SRIOV_VERSION=${IB_SRIOV_VERSION}" >> $GITHUB_OUTPUT
echo "IPOIB_VERSION=${IPOIB_VERSION}" >> $GITHUB_OUTPUT
- name: Login to online register
uses: docker/[email protected]
with:
username: ${{ env.ONLINE_REGISTER_USER }}
password: ${{ env.ONLINE_REGISTER_PASSWORD }}
registry: ${{ env.ONLINE_REGISTER }}
- name: Release build ${{ env.IMAGE_NAME }}
uses: docker/[email protected]
continue-on-error: false
id: docker_build_release
with:
context: ./${{ env.IMAGE_ROOT_PATH }}/${{ env.IMAGE_NAME }}
file: ./${{ env.IMAGE_ROOT_PATH }}/${{ env.IMAGE_NAME }}/Dockerfile
push: true
provenance: false
github-token: ${{ secrets.WELAN_PAT }}
platforms: ${{ env.BUILD_PLATFORM }}
tags: |
${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ steps.arg.outputs.image_tag }}
build-args: |
GIT_COMMIT_HASH=${{ steps.arg.outputs.commit_hash }}
GIT_COMMIT_TIME=${{ steps.arg.outputs.commit_time }}
CNI_VERSION=${{ steps.arg.outputs.CNI_VERSION }}
OVS_VERSION=${{ steps.arg.outputs.OVS_VERSION }}
RDMA_VERSION=${{ steps.arg.outputs.RDMA_VERSION }}
SRIOV_VERSION=${{ steps.arg.outputs.SRIOV_VERSION }}
IB_SRIOV_VERSION=${{ steps.arg.outputs.IB_SRIOV_VERSION }}
IPOIB_VERSION=${{ steps.arg.outputs.IPOIB_VERSION }}
- name: Image Release Digest
if: ${{ env == 'false' }}
shell: bash
run: |
mkdir -p image-digest/
echo "## ${{ env.IMAGE_NAME }}" > image-digest/${{ env.IMAGE_NAME }}.txt
echo "" >> image-digest/${{ env.IMAGE_NAME }}.txt
echo "\`${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ steps.arg.outputs.image_tag }}@${{ steps.docker_build_release.outputs.digest }}\`" >> image-digest/${{ env.IMAGE_NAME }}.txt
echo "" >> image-digest/${{ env.IMAGE_NAME }}.txt
- name: Upload artifact digests
if: ${{ env == 'false' }}
uses: actions/[email protected]
with:
name: image-digest ${{ env.IMAGE_NAME }}
path: image-digest
retention-days: 1
image-digests:
name: Display Digests
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: Downloading Image Digests
shell: bash
run: |
mkdir -p image-digest/
- name: Download digests of all images built
uses: actions/download-artifact@v3
with:
path: image-digest/
- name: Image Digests Output
shell: bash
run: |
cd image-digest/
find -type f | sort | xargs -d '\n' cat