From 6e8dd835d127ce114358893e082fdddaa3a4c44b Mon Sep 17 00:00:00 2001 From: Leonhardt Koepsell Date: Sat, 9 Nov 2024 13:11:14 -0600 Subject: [PATCH] Refactor, update README examples --- next-image-tag-number/Dockerfile | 4 ++-- next-image-tag-number/README.md | 4 ++-- .../{get-next-tag-number.sh => action.sh} | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) rename next-image-tag-number/{get-next-tag-number.sh => action.sh} (81%) diff --git a/next-image-tag-number/Dockerfile b/next-image-tag-number/Dockerfile index f7fc0fc..3dc4970 100644 --- a/next-image-tag-number/Dockerfile +++ b/next-image-tag-number/Dockerfile @@ -1,4 +1,4 @@ FROM alpine:latest RUN apk add --update --no-cache --no-progress curl jq -COPY get-next-tag-number.sh /get-next-tag-number.sh -ENTRYPOINT ["/get-next-tag-number.sh"] +COPY action.sh /action.sh +ENTRYPOINT ["/action.sh"] diff --git a/next-image-tag-number/README.md b/next-image-tag-number/README.md index 4fed3ad..e17292b 100644 --- a/next-image-tag-number/README.md +++ b/next-image-tag-number/README.md @@ -17,7 +17,7 @@ jobs: id: next-tag uses: codebandits/github-actions/next-image-tag-number@main with: - image_repository_url: https://registry.example.com/v2/my-repo/my-image + image_repository_url: registry.example.com/repository/image bearer_token: ${{ secrets.REPO_BEARER_TOKEN }} initial_number: 100 tag_prefix: build- @@ -27,7 +27,7 @@ jobs: ## Inputs -- `image_repository_url:` **Required.** The URL of the OCI-compatible image repository. +- `image_repository_url:` **Required.** The URL of the OCI-compatible image repository. If the protocol is omitted, https is assumed. - `bearer_token:` Optional. The bearer token for repository authentication. Defaults to empty (no authentication). - `initial_number:` Optional. Starting tag number if no tags exist in the repository. Defaults to 1. - `tag_prefix:` Optional. Prefix for the tags. Defaults to build-. diff --git a/next-image-tag-number/get-next-tag-number.sh b/next-image-tag-number/action.sh similarity index 81% rename from next-image-tag-number/get-next-tag-number.sh rename to next-image-tag-number/action.sh index 7ad41ea..2e3de28 100755 --- a/next-image-tag-number/get-next-tag-number.sh +++ b/next-image-tag-number/action.sh @@ -1,6 +1,10 @@ #!/usr/bin/env sh -REPOSITORY_URL=$1 +if ! echo "$1" | grep -q "^http"; then + IMAGE_REPOSITORY_URL="https://$1" +else + IMAGE_REPOSITORY_URL="$1" +fi BEARER_TOKEN=$2 INITIAL_NUMBER=${3:-1} TAG_PREFIX=${4:-"build-"} @@ -11,7 +15,7 @@ else AUTH_HEADER="" fi -TAGS=$(curl -s $AUTH_HEADER "${REPOSITORY_URL}/tags/list" | jq -r '.tags[]' || echo "") +TAGS=$(curl -s $AUTH_HEADER "${IMAGE_REPOSITORY_URL}/tags/list" | jq -r '.tags[]' || echo "") if [ -z "$TAGS" ]; then echo "No existing tags were found. Using initial tag number ${INITIAL_NUMBER}."