Skip to content

Commit

Permalink
Generate Docker Hub Description with current tags (#708)
Browse files Browse the repository at this point in the history
Generate Docker Hub Description with current tags
  • Loading branch information
ldziedziul authored Jan 2, 2024
1 parent 82f50b5 commit 44022e8
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 16 deletions.
50 changes: 50 additions & 0 deletions .github/scripts/generate-docker-hub-description.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

set -eEuo pipefail ${RUNNER_DEBUG:+-x}

get_formatted_latest_docker_tags() {
local REPO_NAME=$1
local PAGE=1
local TAGS=""
while true; do
local RESPONSE=$(curl -s "https://hub.docker.com/v2/repositories/$REPO_NAME/tags/?page=${PAGE}&page_size=100")
local CURRENT_TAGS=$(echo "${RESPONSE}" | jq -r '.results | group_by(.full_size) | .[] | {image: .[0].name, tags: [.[].name]}')
local TAGS="${TAGS}${CURRENT_TAGS}"
local HAS_NEXT=$(echo "${RESPONSE}" | jq -r '.next')
if [ "$HAS_NEXT" == "null" ]; then
break
else
PAGE=$((PAGE + 1))
fi
done

local LATEST_TAGS=$(echo "${TAGS}" | jq -sr '.[] | select(
any(.tags[]; match("^5\\..(-slim)?$|latest"))
)')

echo "${LATEST_TAGS}"| jq -sr '.[] | " - " + (.tags | sort_by(.) | join(", "))' | sort -V
}

fill_readme_with_tags() {
local filename=$1
local repo_name=$2
local matching_line="$3"
local tags_file="tags-$(basename "$repo_name").md"
get_formatted_latest_docker_tags "$repo_name" > "$tags_file"

sed -i -e "/$matching_line/ {
a\
a\
#### Latest Versions
a\
r $tags_file
}" "$filename"

rm "$tags_file"
}

cp README.md README-docker.md
fill_readme_with_tags README-docker.md "hazelcast/hazelcast" "### Hazelcast Versions"
fill_readme_with_tags README-docker.md "hazelcast/hazelcast-enterprise" "### Hazelcast Enterprise Versions"
24 changes: 10 additions & 14 deletions .github/workflows/tag_image_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ jobs:
with:
fetch-depth: 0

- name: Check if latest tag should be pushed
run: |
FILTERED_TAGS=$(git tag --list "v*" | grep -E -v '*BETA*' )
LATEST_TAG=$((IFS=$'\n' && echo "${FILTERED_TAGS[*]}") | sort | tail -n 1)
echo "PUSH_LATEST=$([[ "$LATEST_TAG" = "${GITHUB_REF:10}" ]] && echo yes || echo no)" >> $GITHUB_ENV
- name: Print Push Latest
run: |
echo ${{ env.PUSH_LATEST }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0

Expand Down Expand Up @@ -197,25 +187,31 @@ jobs:
env:
EDITIONS: ${{ github.event.inputs.EDITIONS || 'All' }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .github
- name: Generate Docker Hub Description
run: |
.github/scripts/generate-docker-hub-description.sh
- name: Update Docker Hub Description of OSS image
if: env.PUSH_LATEST == 'yes' && (env.EDITIONS == 'All' || env.EDITIONS == 'OSS' )
if: env.EDITIONS == 'All' || env.EDITIONS == 'OSS'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: hazelcast/hazelcast
short-description: Hazelcast Docker Image
readme-filepath: ./README.md
readme-filepath: ./README-docker.md

- name: Update Docker Hub Description of EE image
if: env.PUSH_LATEST == 'yes' && (env.EDITIONS == 'All' || env.EDITIONS == 'EE' )
if: env.EDITIONS == 'All' || env.EDITIONS == 'EE'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: hazelcast/hazelcast-enterprise
short-description: Hazelcast Enterprise Docker Image
readme-filepath: ./README.md
readme-filepath: ./README-docker.md

- name: Create release
if: github.event_name == 'push'
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ This repository contains Dockerfiles for the official Hazelcast Docker images.

### Hazelcast

You can launch a Hazelcast Docker Container by running the following command. You can find the full list of Hazelcast versions to replace $HAZELCAST_VERSION at the [Official Hazelcast Docker Hub](https://store.docker.com/community/images/hazelcast/hazelcast/tags).
You can launch a Hazelcast Docker Container by running the following command. Check [Hazelcast Versions](#hazelcast-versions) for the versions to replace $HAZELCAST_VERSION.

```
$ docker run hazelcast/hazelcast:$HAZELCAST_VERSION
```
This command will pull a Hazelcast Docker image and run a new Hazelcast instance.

### Hazelcast Versions

You can find the full list of Hazelcast versions at the [Official Hazelcast Docker Hub](https://store.docker.com/community/images/hazelcast/hazelcast/tags).


### Hazelcast Hello World

For the simplest end-to-end scenario, you can create a Hazelcast cluster with two Docker containers and access it from the client application.
Expand All @@ -31,14 +36,18 @@ After setting up the cluster, you can start the [client](https://github.com/haze

### Hazelcast Enterprise

You can launch a Hazelcast Enterprise Docker Container by running the following command. You can find the full list of Hazelcast Enterprise versions to replace $HAZELCAST_VERSION at the [Official Hazelcast Docker Hub](https://store.docker.com/community/images/hazelcast/hazelcast-enterprise/tags).
You can launch a Hazelcast Enterprise Docker Container by running the following command. Check [Hazelcast Enterprise Versions](#hazelcast-enterprise-versions) for the versions to replace $HAZELCAST_VERSION.

Please request a trial license [here](https://hazelcast.com/hazelcast-enterprise-download/) or contact sales@hazelcast.com.

```
$ docker run -e HZ_LICENSEKEY=<your_license_key> hazelcast/hazelcast-enterprise:$HAZELCAST_VERSION
```

### Hazelcast Enterprise Versions

You can find the full list of Hazelcast Enterprise versions at the [Official Hazelcast Docker Hub](https://store.docker.com/community/images/hazelcast/hazelcast-enterprise/tags).

### Hazelcast Enterprise Hello World

To run two Hazelcast nodes, use the following commands.
Expand Down

0 comments on commit 44022e8

Please sign in to comment.