Skip to content

Commit

Permalink
enable image build process for memory-bandwidth-exporter (#452)
Browse files Browse the repository at this point in the history
Signed-off-by: Yingchun Guo <yingchun.guo@intel.com>
  • Loading branch information
daisy-ycguo authored Sep 23, 2024
1 parent a668ff3 commit ddeac46
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 1 deletion.
82 changes: 82 additions & 0 deletions .github/workflows/_mbe-image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Memory Bindwidth Exportor Image Build
permissions: read-all
on:
workflow_call:
inputs:
image_repo:
required: false
type: string
image_tag:
required: true
type: string
runner_label:
required: false
type: string
default: 'docker-build-xeon'
outputs:
image_repo:
description: "The image repository used for the image build"
value: ${{ jobs.image-build.outputs.image_repo }}
image_tag:
description: "The image tag used for the image build"
value: ${{ jobs.image-build.outputs.version }}
env:
GOSRC_DIR: "kubernetes-addons/memory-bandwidth-exporter"

jobs:
image-build:
runs-on: ${{ inputs.runner_label }}
outputs:
image_repo: ${{ steps.set_variables.outputs.IMAGE_REPO }}
version: ${{ steps.set_variables.outputs.VERSION }}
steps:
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*

- name: Get checkout ref
id: get-checkout-ref
run: |
if [ "${{ github.event_name }}" == "pull_request" ] || [ "${{ github.event_name }}" == "pull_request_target" ]; then
CHECKOUT_REF=refs/pull/${{ github.event.number }}/merge
else
CHECKOUT_REF=${{ github.ref }}
fi
echo "CHECKOUT_REF=${CHECKOUT_REF}" >> $GITHUB_OUTPUT
echo "checkout ref ${CHECKOUT_REF}"
- name: Checkout out Repo
uses: actions/checkout@v4
with:
ref: ${{ steps.get-checkout-ref.outputs.CHECKOUT_REF }}
fetch-depth: 0

- name: Set variables
id: set_variables
env:
imagerepo: ${{ inputs.image_repo }}
run: |
if [[ -z "$imagerepo" ]]; then
echo "DOCKER_REGISTRY=${OPEA_IMAGE_REPO}opea" >> $GITHUB_ENV
echo "IMAGE_REPO=${OPEA_IMAGE_REPO}" >> $GITHUB_OUTPUT
else
echo "DOCKER_REGISTRY=${imagerepo}/opea" >> $GITHUB_ENV
echo "IMAGE_REPO=${imagerepo}/" >> $GITHUB_OUTPUT
fi
echo "VERSION=${{ inputs.image_tag }}" >> $GITHUB_ENV
echo "VERSION=${{ inputs.image_tag }}" >> $GITHUB_OUTPUT
- name: Build image and push
run: |
cd $GOSRC_DIR
make docker.build
make docker.push
- name: Clean up images
if: always()
run: |
# clean up the images
docker rmi ${{ env.DOCKER_REGISTRY }}/memory-bandwidth-exporter:${{ env.VERSION }}
echo y | docker image prune
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- "!**.txt"
- "!**.png"
- "!.**"
- .github/workflows/gmc-on-push.yaml
- .github/workflows/push-gmc-image-build.yaml
workflow_dispatch:

concurrency:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/push-mbe-image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Upgrade memory bandwidth exporter on push event

on:
push:
branches: ["main"]
paths:
- kubernetes-addons/memory-bandwidth-exporter/**
- "!**.md"
- "!**.txt"
- "!**.png"
- "!.**"
- .github/workflows/push-mbe-image-build.yaml
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-on-push
cancel-in-progress: true

env:
GOSRC_DIR: "kubernetes-addons/memory-bandwidth-exporter"

jobs:
image-build:
strategy:
matrix:
platform: [xeon, gaudi]
uses: ./.github/workflows/_mbe-image-build.yaml
with:
image_tag: 'latest'
runner_label: 'docker-build-${{ matrix.platform }}'

0 comments on commit ddeac46

Please sign in to comment.