Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion ci/build_image → ci/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down