Skip to content

Commit

Permalink
Refactor, update README examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lnhrdt committed Nov 9, 2024
1 parent e60e1ae commit 6e8dd83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions next-image-tag-number/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 2 additions & 2 deletions next-image-tag-number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-
Expand All @@ -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-.
Expand Down
Original file line number Diff line number Diff line change
@@ -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-"}
Expand All @@ -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}."
Expand Down

0 comments on commit 6e8dd83

Please sign in to comment.