From 78aad3dc315b2750a703ce2d2eb5c1d4fe851bc2 Mon Sep 17 00:00:00 2001 From: Achref ben saad Date: Mon, 14 Nov 2022 04:12:59 +0000 Subject: [PATCH] add labels to docker image --- .github/workflows/latest-release.yml | 4 ++-- .github/workflows/stable-release.yml | 2 +- src/build/push_knoxautopolicy.sh | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/latest-release.yml b/.github/workflows/latest-release.yml index 6d34c1fe..acc2dbbf 100644 --- a/.github/workflows/latest-release.yml +++ b/.github/workflows/latest-release.yml @@ -64,7 +64,7 @@ jobs: - name: Push discovery engine images to Docker run: | - ./src/build/push_knoxautopolicy.sh ${{ steps.vars.outputs.tag }} + GITHUB_SHA=$GITHUB_SHA ./src/build/push_knoxautopolicy.sh ${{ steps.vars.outputs.tag }} push-stable-version: name: Create discovery engine Release - 20.04 @@ -99,5 +99,5 @@ jobs: - name: Push discovery engine images to Docker if: steps.match.outputs.tag == 'true' - run: ./src/build/push_knoxautopolicy.sh stable + run: GITHUB_SHA=$GITHUB_SHA STABLE_VERSION=$(cat STABLE-RELEASE) ./src/build/push_knoxautopolicy.sh stable diff --git a/.github/workflows/stable-release.yml b/.github/workflows/stable-release.yml index f51d58f1..6d435bc1 100644 --- a/.github/workflows/stable-release.yml +++ b/.github/workflows/stable-release.yml @@ -40,4 +40,4 @@ jobs: platforms: linux/amd64,linux/arm64/v8 - name: Push discovery engine images to Docker - run: ./src/build/push_knoxautopolicy.sh stable + run: GITHUB_SHA=$GITHUB_SHA STABLE_VERSION=$(cat STABLE-RELEASE) ./src/build/push_knoxautopolicy.sh stable diff --git a/src/build/push_knoxautopolicy.sh b/src/build/push_knoxautopolicy.sh index fb6009b6..a1a2ad61 100755 --- a/src/build/push_knoxautopolicy.sh +++ b/src/build/push_knoxautopolicy.sh @@ -8,6 +8,12 @@ AUTOPOL_SRC_HOME=$AUTOPOL_HOME/src [[ "$PLATFORMS" == "" ]] && PLATFORMS="linux/amd64" #[[ "$PLATFORMS" == "" ]] && PLATFORMS="linux/amd64,linux/arm64/v8" +[[ "$STABLE_VERSION" != "" ]] && STABLE_LABEL="--label stable-version=$STABLE_VERSION" + +# set LABEL +unset LABEL +[[ "$GITHUB_SHA" != "" ]] && LABEL="--label github_sha=$GITHUB_SHA" + # check version VERSION=`git rev-parse --abbrev-ref HEAD` @@ -16,7 +22,7 @@ if [ ! -z $1 ]; then fi echo "[INFO] Pushing $REPO:$VERSION" -docker buildx build --platform $PLATFORMS --push -t $REPO:$VERSION -f $AUTOPOL_SRC_HOME/build/Dockerfile.autopol . +docker buildx build --platform $PLATFORMS --push -t $REPO:$VERSION -f $AUTOPOL_SRC_HOME/build/Dockerfile.autopol $STABLE_VERSION $LABEL . if [ $? != 0 ]; then echo "[FAILED] Failed to push $REPO:$VERSION"