From cb2afc447545360d04b34d556501366da014f091 Mon Sep 17 00:00:00 2001 From: stolsma Date: Wed, 23 Feb 2022 12:20:51 +0100 Subject: [PATCH] Refactor makefile, add ubuntu1804 and fix label bug Add Ubuntu 18.04 as checked base image. Refactor build, push and export steps Fix label bug where label data with comma is truncated Signed-off-by: stolsma --- .github/workflows/makefile.yml | 35 +++++++++++++--------------------- build/scripts/ipdk.sh | 8 +++++++- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 0644ab2c..6ed42907 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -27,7 +27,7 @@ jobs: matrix: # for OCI runner change to: runner: [ubuntu-latest, self-hosted] runner: [ubuntu-latest] - os: [ubuntu2004, fedora33] + os: [ubuntu2004, ubuntu1804, fedora33] steps: - name: Checkout repository @@ -45,13 +45,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 -# - name: Login to DockerHub -# if: github.event_name != 'pull_request' -# uses: docker/login-action@v1 -# with: -# username: ${{ secrets.DOCKERHUB_USERNAME }} -# password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Login to GitHub Container Registry if: github.event_name != 'pull_request' uses: docker/login-action@v1 @@ -86,21 +79,19 @@ jobs: ./ipdk install ${{ matrix.os }} ipdk config IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/ipdk-${{ matrix.os }}-${{ steps.system.outputs.arch }} - - name: IPDK image build and push - if: github.event_name != 'pull_request' - run: | - ipdk build --no-cache \ - --tags "${{ steps.image_meta.outputs.tags }}" \ - --labels "${{ steps.image_meta.outputs.labels }}" \ - --push - - - name: IPDK image build and export - if: github.event_name == 'pull_request' + - name: IPDK image build and export or push run: | - ipdk build --no-cache \ - --tags "${{ steps.image_meta.outputs.tags }}" \ - --labels "${{ steps.image_meta.outputs.labels }}" \ - --export /tmp/${{ matrix.os }}-${{ steps.system.outputs.arch }}.tar + if [ "${{ github.event_name }}" = "pull_request" ]; then + ipdk build --no-cache \ + --tags "${{ steps.image_meta.outputs.tags }}" \ + --labels "${{ steps.image_meta.outputs.labels }}" \ + --export /tmp/${{ matrix.os }}-${{ steps.system.outputs.arch }}.tar + else + ipdk build --no-cache \ + --tags "${{ steps.image_meta.outputs.tags }}" \ + --labels "${{ steps.image_meta.outputs.labels }}" \ + --push + fi - name: Upload build artifact if: github.event_name == 'pull_request' diff --git a/build/scripts/ipdk.sh b/build/scripts/ipdk.sh index 7aa71fbc..95f76391 100755 --- a/build/scripts/ipdk.sh +++ b/build/scripts/ipdk.sh @@ -143,7 +143,13 @@ build_image() { if [[ "$LABELS" != "" ]] ; then IFS="," read -r -a LABEL_LIST <<< "${LABELS}" for i in "${LABEL_LIST[@]}" ; do - ARGS+=("--label" "${i}") + if [[ "$i" == *"="* ]]; then # solve the use of , in label string... + ARGS+=("--label" "${i}") + else + local LAST_INDEX=${#ARGS[@]}-1 + local TEMP=${ARGS[${LAST_INDEX}]} + ARGS[${LAST_INDEX}]="${TEMP},${i}" + fi done fi