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
19 changes: 12 additions & 7 deletions .github/workflows/publish-cli-runtime-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
publish:
name: Publish CLI Runtime Image
runs-on: ubuntu-latest
env:
IMAGE_REPO: ghcr.io/${{ github.repository_owner }}/labview-cdev-cli-runtime
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -48,6 +46,12 @@ jobs:

date_utc="$(date -u +%Y%m%d)"
short_sha="${GITHUB_SHA:0:12}"
owner_lc="$(printf '%s' "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
if [[ -z "$owner_lc" ]]; then
echo "github repository owner is empty" >&2
exit 1
fi
image_repo="ghcr.io/${owner_lc}/labview-cdev-cli-runtime"
promote_v1="${{ github.event.inputs.promote_v1 }}"
additional_tag="${{ github.event.inputs.additional_tag }}"

Expand All @@ -61,18 +65,19 @@ jobs:
fi

tags=()
tags+=("${IMAGE_REPO}:sha-${short_sha}")
tags+=("${IMAGE_REPO}:v1-${date_utc}")
tags+=("${image_repo}:sha-${short_sha}")
tags+=("${image_repo}:v1-${date_utc}")
if [[ "$promote_v1" == "true" ]]; then
tags+=("${IMAGE_REPO}:v1")
tags+=("${image_repo}:v1")
fi
if [[ -n "$additional_tag" ]]; then
tags+=("${IMAGE_REPO}:${additional_tag}")
tags+=("${image_repo}:${additional_tag}")
fi

{
echo "date_utc=$date_utc"
echo "short_sha=$short_sha"
echo "image_repo=$image_repo"
echo "tags<<EOF"
printf '%s\n' "${tags[@]}"
echo "EOF"
Expand Down Expand Up @@ -103,7 +108,7 @@ jobs:
{
echo "## cdev CLI Runtime Image Published"
echo ""
echo "- Image: \`${IMAGE_REPO}\`"
echo "- Image: \`${{ steps.resolve.outputs.image_repo }}\`"
echo "- Digest: \`${{ steps.build.outputs.digest }}\`"
echo "- Commit: \`${GITHUB_SHA}\`"
echo "- Tags:"
Expand Down
3 changes: 2 additions & 1 deletion tests/CdevCliRuntimeImagePublishContract.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Describe 'cdev CLI runtime image publish contract' {
$script:workflow | Should -Match 'workflow_dispatch:'
$script:workflow | Should -Match 'push:'
$script:workflow | Should -Match 'packages:\s*write'
$script:workflow | Should -Match 'ghcr\.io/\$\{\{\s*github\.repository_owner\s*\}\}/labview-cdev-cli-runtime'
$script:workflow | Should -Match "tr '\[:upper:\]' '\[:lower:\]'"
$script:workflow | Should -Match 'image_repo="ghcr\.io/\$\{owner_lc\}/labview-cdev-cli-runtime"'
$script:workflow | Should -Match 'docker/login-action@v3'
$script:workflow | Should -Match 'docker/build-push-action@v6'
}
Expand Down