Skip to content

Commit 9b68424

Browse files
committed
use docker pushrm to update README on Docker Hub
fixes #4016
1 parent fa34e4f commit 9b68424

File tree

2 files changed

+12
-40
lines changed

2 files changed

+12
-40
lines changed

.github/workflows/docker.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ jobs:
1616
OPENGROK_PULL_REQUEST: ${{ github.head_ref }}
1717
OPENGROK_REF: ${{ github.ref }}
1818
run: ./dev/docker.sh
19+
- name: push README to Dockerhub on release
20+
if: startsWith(github.ref, 'refs/tags/v')
21+
uses: christian-korneck/update-container-description-action@v1
22+
env:
23+
DOCKER_USER: ${{ secrets.DOCKER_USERNAME }}
24+
DOCKER_PASS: ${{ secrets.DOCKER_PASSWORD }}
25+
with:
26+
destination_container_repo: opengrok/docker
27+
provider: dockerhub
28+
short_description: 'Official OpenGrok Docker image'
29+
readme_file: 'docker/README.md'

dev/docker.sh

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,6 @@
1212

1313
set -e
1414

15-
# Update README file in Docker hub.
16-
push_readme() {
17-
declare -r image="${1}"
18-
declare -r token="${2}"
19-
declare -r input_file="${3}"
20-
21-
if [[ ! -r $input_file ]]; then
22-
echo "file $input_file is not readable"
23-
exit 1
24-
fi
25-
26-
local code=$(curl -s -o /dev/null -L -w "%{http_code}" \
27-
-X PATCH \
28-
--data-urlencode full_description@${input_file} \
29-
-H "Content-Type: application/json" \
30-
-H "Authorization: JWT ${token}" \
31-
${API_URL}/repositories/"${image}"/)
32-
33-
if [[ "${code}" = "200" ]]; then
34-
echo "Successfully pushed README to Docker Hub"
35-
else
36-
printf "Unable to push README to Docker Hub, response code: %s\n" "${code}"
37-
exit 1
38-
fi
39-
}
40-
4115
echo "Running linter"
4216
docker run --rm -i hadolint/hadolint:2.6.0 < Dockerfile || exit 1
4317

@@ -119,17 +93,4 @@ if [ -n "$DOCKER_PASSWORD" -a -n "$DOCKER_USERNAME" -a -n "$TAGS" ]; then
11993
echo "Pushing Docker image for tag $tag"
12094
docker push $IMAGE:$tag
12195
done
122-
fi
123-
124-
# Update README and badge only for release builds.
125-
if [[ -n $OPENGROK_TAG ]]; then
126-
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST \
127-
-d '{"username": "'${DOCKER_USERNAME}'", "password": "'${DOCKER_PASSWORD}'"}' \
128-
${API_URL}/users/login/ | jq -r .token)
129-
if [[ -z $TOKEN ]]; then
130-
echo "Cannot get auth token to publish the README file"
131-
exit 1
132-
fi
133-
134-
push_readme "${IMAGE}" "${TOKEN}" "docker/README.md"
135-
fi
96+
fi

0 commit comments

Comments
 (0)