From 7efa2d069b729215c7ff22b9af3b55c97d6dda1a Mon Sep 17 00:00:00 2001 From: "Tj (bougyman) Vanderpoel" Date: Mon, 3 Jun 2024 11:09:58 -0500 Subject: [PATCH] fix(build): Corrects name of image build script --- .github/workflows/container.yaml | 24 +++++++++++++++++++++--- ci/{build_image => build_image.sh} | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) rename ci/{build_image => build_image.sh} (97%) diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml index 9144f05..6367311 100644 --- a/.github/workflows/container.yaml +++ b/.github/workflows/container.yaml @@ -2,7 +2,15 @@ name: Publish OCI Container on: # yamllint disable-line rule:truthy workflow_call: + inputs: + tag: + description: 'The tag to use for the container image' + required: false workflow_dispatch: + inputs: + tag: + description: 'The tag to use for the container image' + required: false jobs: publish_github: name: Publish the container image to GitHub Container Registry @@ -16,12 +24,22 @@ jobs: env: TRACE: ${{ secrets.ACTIONS_STEP_DEBUG || 'false' }} REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.event.inputs.tag || '' }} run: | - if [ -f ".version.txt" ] + if [ -z "$TAG" ] then - version=$(<.version.txt) + [ "$TRACE" = true ] && printf 'No tag provided, getting tag from .version.txt\n' >&2 + if [ -f ".version.txt" ] + then + version=$(<.version.txt) + else + [ "$TRACE" = true ] && printf 'No .version.txt found, getting version from git describe --tags --abbrev=0\n' >&2 + version=$(git describe --tags --abbrev=0) + fi else - version=$(git describe --tags --abbrev=0) + [ "$TRACE" = true ] && printf 'Using provided tag %s\n' "$TAG" >&2 + version=$TAG fi + [ "$TRACE" = 'true' ] && printf 'Calling ./ci/build_image.sh -vvp "%s"\n' "$version" >&2 GITHUB_TOKEN=$REGISTRY_TOKEN ./ci/build_image.sh -vvp "$version" shell: bash diff --git a/ci/build_image b/ci/build_image.sh similarity index 97% rename from ci/build_image rename to ci/build_image.sh index 5f0af06..9c5a6b0 100755 --- a/ci/build_image +++ b/ci/build_image.sh @@ -220,7 +220,7 @@ then printf "%s" "$GITHUB_TOKEN" | $runtime login -u "$GITHUB_TOKEN" --password-stdin "$REGISTRY" || die 10 "Failed to login to $REGISTRY" fi -tags=($(echo "$tag" | awk -F'.' 'NF==3{print $1"."$2"."$3" "$1"."$2" "$1} NF==2{print $1"."$2" "$1} NF==1{print $1}')) +mapfile -t tags < <(echo "$tag" | awk -F'.' 'NF==3{print $1"."$2"."$3; print $1"."$2; print $1; next} NF==2{print $1"."$2; print $1; next} {print}') for t in "${tags[@]}" do proper_tag=$IMAGE_NAME:$tag