Skip to content

Commit

Permalink
[fix] Remove command echoing (#6126)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Part of #3842

## Description of the changes
- Remove echoing of commands from upload script
- remove test file that doesn't check much

Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro authored Oct 27, 2024
1 parent 85d558d commit 6a0a5c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 52 deletions.
21 changes: 11 additions & 10 deletions scripts/upload-docker-readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# Copyright (c) 2024 The Jaeger Authors.
# SPDX-License-Identifier: Apache-2.0

set -euxf -o pipefail
set -euf -o pipefail

usage() {
echo "Usage: $0 <repository_name> <file_path>"
exit 1
}

if [ "$#" -ne 2 ]; then
echo "Error: Missing arguments."
echo "🛑 Error: Missing arguments."
usage
fi

Expand All @@ -26,13 +26,14 @@ dockerhub_url="https://hub.docker.com/v2/repositories/$repository/"
quay_url="https://quay.io/api/v1/repository/${repository}"

if [ ! -f "$abs_readme_path" ]; then
echo "Warning: no README file found at path $abs_readme_path"
echo "It is recommended to have a dedicated README file for each Docker image"
echo "🟡 Warning: no README file found at path $abs_readme_path"
echo "🟡 It is recommended to have a dedicated README file for each Docker image"
exit 0
fi

readme_content=$(<"$abs_readme_path")

# do not echo commands as they contain tokens
set +x

# Handling DockerHUB upload
Expand All @@ -43,17 +44,17 @@ body=$(jq -n \

dockerhub_response=$(curl -s -w "%{http_code}" -X PATCH "$dockerhub_url" \
-H "Content-Type: application/json" \
-H "Authorization: JWT $DOCKERHUB_TOKEN" \
-H "Authorization: Bearer $DOCKERHUB_TOKEN" \
-d "$body")

http_code="${dockerhub_response: -3}"
response_body="${dockerhub_response:0:${#dockerhub_response}-3}"

if [ "$http_code" -eq 200 ]; then
echo "Successfully updated Docker Hub README for $repository"
echo "Successfully updated Docker Hub README for $repository"
else
echo "🛑 Failed to update Docker Hub README for $repository with status code $http_code"
echo "Full response: $response_body"
echo "🛑 Full response: $response_body"
fi

# Handling Quay upload
Expand All @@ -71,8 +72,8 @@ quay_http_code="${quay_response: -3}"
quay_response_body="${quay_response:0:${#quay_response}-3}"

if [ "$quay_http_code" -eq 200 ]; then
echo "Successfully updated Quay.io README for $repository"
echo "Successfully updated Quay.io README for $repository"
else
echo "Failed to update Quay.io README for $repository with status code $quay_http_code"
echo "Full response: $quay_response_body"
echo "🛑 Failed to update Quay.io README for $repository with status code $quay_http_code"
echo "🛑 Full response: $quay_response_body"
fi
42 changes: 0 additions & 42 deletions scripts/upload-docker-readme.test.sh

This file was deleted.

0 comments on commit 6a0a5c5

Please sign in to comment.