From 2517a5c95d480baf8bdf01c3e81ba0aa3303c3f4 Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Thu, 4 Feb 2021 10:07:31 +0800 Subject: [PATCH 1/9] Push all images to quay.io and docker.io Signed-off-by: Ashmita Bohara --- .github/workflows/ci-all-in-one-build.yml | 17 +--- .github/workflows/ci-crossdock.yml | 17 +--- .github/workflows/ci-docker-build.yml | 17 +--- .github/workflows/ci-hotrod.yml | 17 +--- .github/workflows/ci-release.yml | 20 ++-- scripts/travis/build-all-in-one-image.sh | 19 ++-- scripts/travis/build-crossdock.sh | 19 ++-- scripts/travis/hotrod-integration-test.sh | 19 ++-- scripts/travis/upload-all-docker-images.sh | 19 ++-- scripts/travis/upload-to-docker.sh | 44 --------- scripts/travis/upload-to-registry.sh | 109 +++++++++++++++++++++ 11 files changed, 175 insertions(+), 142 deletions(-) delete mode 100755 scripts/travis/upload-to-docker.sh create mode 100755 scripts/travis/upload-to-registry.sh diff --git a/.github/workflows/ci-all-in-one-build.yml b/.github/workflows/ci-all-in-one-build.yml index 1238c1936ad..8c07671f98c 100644 --- a/.github/workflows/ci-all-in-one-build.yml +++ b/.github/workflows/ci-all-in-one-build.yml @@ -26,20 +26,6 @@ jobs: with: node-version: '10' - - uses: docker/login-action@v1 - id: dockerhub-login - with: - username: jaegertracingbot - password: ${{ secrets.DOCKERHUB_TOKEN }} - env: - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - if: env.DOCKERHUB_TOKEN != null - - - name: Export DOCKERHUB_LOGIN variable - run: | - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - if: steps.dockerhub-login.outcome == 'success' - - name: Export BRANCH variable uses: ./.github/actions/setup-branch @@ -48,3 +34,6 @@ jobs: - name: Build, test, and publish all-in-one image run: bash scripts/travis/build-all-in-one-image.sh + env: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} diff --git a/.github/workflows/ci-crossdock.yml b/.github/workflows/ci-crossdock.yml index 7399eb92425..37628e00a78 100644 --- a/.github/workflows/ci-crossdock.yml +++ b/.github/workflows/ci-crossdock.yml @@ -30,20 +30,6 @@ jobs: with: go-version: ^1.15 - - uses: docker/login-action@v1 - id: dockerhub-login - with: - username: jaegertracingbot - password: ${{ secrets.DOCKERHUB_TOKEN }} - env: - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - if: env.DOCKERHUB_TOKEN != null - - - name: Export DOCKERHUB_LOGIN variable - run: | - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - if: steps.dockerhub-login.outcome == 'success' - - name: Export BRANCH variable uses: ./.github/actions/setup-branch @@ -52,6 +38,9 @@ jobs: - name: Build, test, and publish ${{ matrix.steps.name }} image run: ${{ matrix.steps.cmd }} + env: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} - name: Output crossdock logs run: make crossdock-logs diff --git a/.github/workflows/ci-docker-build.yml b/.github/workflows/ci-docker-build.yml index 071977351d0..ef5d49c1bf6 100644 --- a/.github/workflows/ci-docker-build.yml +++ b/.github/workflows/ci-docker-build.yml @@ -26,20 +26,6 @@ jobs: with: node-version: '10' - - uses: docker/login-action@v1 - id: dockerhub-login - with: - username: jaegertracingbot - password: ${{ secrets.DOCKERHUB_TOKEN }} - env: - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - if: env.DOCKERHUB_TOKEN != null - - - name: Export DOCKERHUB_LOGIN variable - run: | - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - if: steps.dockerhub-login.outcome == 'success' - - name: Export BRANCH variable uses: ./.github/actions/setup-branch @@ -51,3 +37,6 @@ jobs: - name: Upload docker images run: bash scripts/travis/upload-all-docker-images.sh + env: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} diff --git a/.github/workflows/ci-hotrod.yml b/.github/workflows/ci-hotrod.yml index e94e037026d..4c2d2defd3a 100644 --- a/.github/workflows/ci-hotrod.yml +++ b/.github/workflows/ci-hotrod.yml @@ -22,20 +22,6 @@ jobs: with: go-version: ^1.15 - - uses: docker/login-action@v1 - id: dockerhub-login - with: - username: jaegertracingbot - password: ${{ secrets.DOCKERHUB_TOKEN }} - env: - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - if: env.DOCKERHUB_TOKEN != null - - - name: Export DOCKERHUB_LOGIN variable - run: | - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - if: steps.dockerhub-login.outcome == 'success' - - name: Export BRANCH variable uses: ./.github/actions/setup-branch @@ -44,3 +30,6 @@ jobs: - name: Build, test, and publish hotrod image run: bash scripts/travis/hotrod-integration-test.sh + env: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 9d187770e2a..4457fde1022 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -25,20 +25,6 @@ jobs: with: node-version: '10' - - uses: docker/login-action@v1 - id: dockerhub-login - with: - username: jaegertracingbot - password: ${{ secrets.DOCKERHUB_TOKEN }} - env: - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - if: env.DOCKERHUB_TOKEN != null - - - name: Export DOCKERHUB_LOGIN variable - run: | - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - if: steps.dockerhub-login.outcome == 'success' - - name: Export BRANCH variable uses: ./.github/actions/setup-branch @@ -70,6 +56,12 @@ jobs: - name: Upload docker images run: bash scripts/travis/upload-all-docker-images.sh if: steps.build-images.outcome == 'success' + env: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} - name: Build, test, and publish all-in-one image run: bash scripts/travis/build-all-in-one-image.sh + env: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} diff --git a/scripts/travis/build-all-in-one-image.sh b/scripts/travis/build-all-in-one-image.sh index ea83296969b..253d5130ae1 100755 --- a/scripts/travis/build-all-in-one-image.sh +++ b/scripts/travis/build-all-in-one-image.sh @@ -7,7 +7,6 @@ BRANCH=${BRANCH:?'missing BRANCH env var'} # be overrided by passing architecture value to the script: # `GOARCH= ./scripts/travis/build-all-in-one-image.sh`. GOARCH=${GOARCH:-$(go env GOARCH)} -DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false} expected_version="v10" version=$(node --version) @@ -36,13 +35,19 @@ run_integration_test() { } upload_to_docker() { - # Only push the docker container to Docker Hub for master/release branch and when dockerhub login is done - if [[ ("$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$) && "$DOCKERHUB_LOGIN" == "true" ]]; then - echo "upload $1 to Docker Hub" - export REPO=$1 - bash ./scripts/travis/upload-to-docker.sh + DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} + DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} + QUAY_USERNAME=${QUAY_USERNAME:-} + QUAY_TOKEN=${QUAY_TOKEN:-} + + # Only push the docker image to dockerhub/quay.io for master/release branch + if [[ "$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "upload $1 to dockerhub/quay.io" + REPO=$1 + bash scripts/travis/upload-to-registry.sh "docker.io" $REPO $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN + bash scripts/travis/upload-to-registry.sh "quay.io" $REPO $QUAY_USERNAME $QUAY_TOKEN else - echo 'skip docker upload for PR' + echo 'skip docker images upload for PR' fi } diff --git a/scripts/travis/build-crossdock.sh b/scripts/travis/build-crossdock.sh index 6045a589c15..1eca4283bb1 100755 --- a/scripts/travis/build-crossdock.sh +++ b/scripts/travis/build-crossdock.sh @@ -3,20 +3,25 @@ set -euxf -o pipefail BRANCH=${BRANCH:?'missing BRANCH env var'} -DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false} COMMIT=${GITHUB_SHA::8} make build-and-run-crossdock -# Only push the docker container to Docker Hub for master branch and when dockerhub login is done -if [[ "$BRANCH" == "master" && "$DOCKERHUB_LOGIN" == "true" ]]; then - echo 'upload to Docker Hub' +# Only push images to dockerhub/quay.io for master branch +if [[ "$BRANCH" == "master" ]]; then + echo 'upload images to dockerhub/quay.io' else - echo 'skip docker upload for PR' + echo 'skip docker images upload for PR' exit 0 fi +DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} +DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} +QUAY_USERNAME=${QUAY_USERNAME:-} +QUAY_TOKEN=${QUAY_TOKEN:-} + # docker image has been build when running the crossdock -export REPO=jaegertracing/test-driver +REPO=jaegertracing/test-driver docker tag $REPO:latest $REPO:$COMMIT -bash ./scripts/travis/upload-to-docker.sh +bash scripts/travis/upload-to-registry.sh "docker.io" $REPO $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN +bash scripts/travis/upload-to-registry.sh "quay.io" $REPO $QUAY_USERNAME $QUAY_TOKEN diff --git a/scripts/travis/hotrod-integration-test.sh b/scripts/travis/hotrod-integration-test.sh index 43084cbb0f6..261ca02168d 100755 --- a/scripts/travis/hotrod-integration-test.sh +++ b/scripts/travis/hotrod-integration-test.sh @@ -3,7 +3,7 @@ set -euxf -o pipefail make docker-hotrod -export REPO=jaegertracing/example-hotrod +REPO=jaegertracing/example-hotrod export CID=$(docker run -d -p 8080:8080 $REPO:latest) i=0 while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080)" != "200" && ${i} < 30 ]]; do @@ -18,14 +18,19 @@ fi docker rm -f $CID BRANCH=${BRANCH:?'missing BRANCH env var'} -DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false} -# Only push images to Docker Hub for master branch or for release tags vM.N.P and when dockerhub login is done -if [[ ("$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$) && "$DOCKERHUB_LOGIN" == "true" ]]; then - echo "upload to Docker Hub, BRANCH=$BRANCH" +# Only push images to dockerhub/quay.io for master branch or for release tags vM.N.P +if [[ "$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "upload to dockerhub/quay.io, BRANCH=$BRANCH" else - echo "skip Docker upload, only allowed for tagged releases or master (latest tag)" + echo "skip docker images upload, only allowed for tagged releases or master (latest tag)" exit 0 fi -bash ./scripts/travis/upload-to-docker.sh +DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} +DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} +QUAY_USERNAME=${QUAY_USERNAME:-} +QUAY_TOKEN=${QUAY_TOKEN:-} + +bash scripts/travis/upload-to-registry.sh "docker.io" $REPO $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN +bash scripts/travis/upload-to-registry.sh "quay.io" $REPO $QUAY_USERNAME $QUAY_TOKEN diff --git a/scripts/travis/upload-all-docker-images.sh b/scripts/travis/upload-all-docker-images.sh index 2fc33892c61..41537ade9c0 100755 --- a/scripts/travis/upload-all-docker-images.sh +++ b/scripts/travis/upload-all-docker-images.sh @@ -5,13 +5,12 @@ set -euxf -o pipefail BRANCH=${BRANCH:?'missing BRANCH env var'} -DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false} -# Only push images to Docker Hub for master branch or for release tags vM.N.P and when dockerhub login is done -if [[ ("$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$) && "$DOCKERHUB_LOGIN" == "true" ]]; then - echo "upload to Docker Hub, BRANCH=$BRANCH" +# Only push images to dockerhub/quay.io for master branch or for release tags vM.N.P +if [[ "$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "upload to dockerhub/quay.io, BRANCH=$BRANCH" else - echo 'skip Docker upload, only allowed for tagged releases or master (latest tag)' + echo 'skip docker images upload, only allowed for tagged releases or master (latest tag)' exit 0 fi @@ -36,8 +35,14 @@ jaeger_components=( opentelemetry-ingester ) +DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} +DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} +QUAY_USERNAME=${QUAY_USERNAME:-} +QUAY_TOKEN=${QUAY_TOKEN:-} + for component in "${jaeger_components[@]}" do - export REPO="jaegertracing/jaeger-${component}" - bash ./scripts/travis/upload-to-docker.sh + REPO="jaegertracing/jaeger-${component}" + bash scripts/travis/upload-to-registry.sh "docker.io" $REPO $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN + bash scripts/travis/upload-to-registry.sh "quay.io" $REPO $QUAY_USERNAME $QUAY_TOKEN done diff --git a/scripts/travis/upload-to-docker.sh b/scripts/travis/upload-to-docker.sh deleted file mode 100755 index 55fdcdb2dab..00000000000 --- a/scripts/travis/upload-to-docker.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -set -euxf -o pipefail - -BRANCH=${BRANCH:?'missing BRANCH env var'} -IMAGE="${REPO:?'missing REPO env var'}:latest" - -unset major minor patch -if [[ "$BRANCH" == "master" ]]; then - TAG="latest" -elif [[ $BRANCH =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then - major="${BASH_REMATCH[1]}" - minor="${BASH_REMATCH[2]}" - patch="${BASH_REMATCH[3]}" - TAG=${major}.${minor}.${patch} - echo "BRANCH is a release tag: major=$major, minor=$minor, patch=$patch" -else - TAG="${BRANCH}" -fi -echo "REPO=$REPO, BRANCH=$BRANCH, TAG=$TAG, IMAGE=$IMAGE" - -# add major, major.minor and major.minor.patch tags -if [[ -n ${major:-} ]]; then - docker tag $IMAGE $REPO:${major} - if [[ -n ${minor:-} ]]; then - docker tag $IMAGE $REPO:${major}.${minor} - if [[ -n ${patch:-} ]]; then - docker tag $IMAGE $REPO:${major}.${minor}.${patch} - fi - fi -fi - -if [[ "${REPO}" == "jaegertracing/jaeger-opentelemetry-collector" || "${REPO}" == "jaegertracing/jaeger-opentelemetry-agent" || "${REPO}" == "jaegertracing/jaeger-opentelemetry-ingester" || "${REPO}" == "jaegertracing/opentelemetry-all-in-one" ]]; then - # TODO remove once Jaeger OTEL collector is stable - docker push $REPO:latest -else - # push all tags, therefore push to repo - docker push $REPO -fi - -SNAPSHOT_IMAGE="$REPO-snapshot:$GITHUB_SHA" -echo "Pushing snapshot image $SNAPSHOT_IMAGE" -docker tag $IMAGE $SNAPSHOT_IMAGE -docker push $SNAPSHOT_IMAGE diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh new file mode 100755 index 00000000000..091b8ab81b2 --- /dev/null +++ b/scripts/travis/upload-to-registry.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +set -euxf -o pipefail + +usage() { + echo $"Usage: $0 " + exit 1 +} + +check_args() { + if [ ! $# -eq 4 ]; then + echo "ERROR: need exactly four arguments" + usage + fi +} + +compute_image_tag() { + local branch=$1 + + if [[ "${branch}" == "master" ]]; then + local tag="latest" + echo ${tag} + elif [[ "${branch}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + local major="${BASH_REMATCH[1]}" + local minor="${BASH_REMATCH[2]}" + local patch="${BASH_REMATCH[3]}" + local tag=${major}.${minor}.${patch} + echo "${tag} ${major} ${minor} ${patch}" + else + local tag="${branch}" + echo ${tag} + fi +} + +label_release_tag() { + local registry=$1 + local image=$2 + local major=${3:-} + local minor=${4:-} + local patch=${5:-} + + if [[ -n ${major} ]]; then + docker tag ${image} ${registry}/${image}:${major} + if [[ -n ${minor} ]]; then + docker tag ${image} ${registry}/${image}:${major}.${minor} + if [[ -n ${patch} ]]; then + docker tag ${image} ${registry}/${image}:${major}.${minor}.${patch} + fi + fi + fi +} + +try_login() { + local registry=$1 + local user=$2 + local token=$3 + local marker=.${registry}.login + + if [ ! -f ${marker} ]; then + printenv ${token} | docker login ${registry} --username ${user} --password-stdin + if [ $? -eq 0 ]; then + touch ${marker} + fi + fi +} + +upload_images() { + local registry=$1 + local image=$2 + local user=$3 + local token=$4 + local marker=.${registry}.login + + try_login ${registry} ${user} ${token} + + # upload regular images + if [ ! -f ${marker} ]; then + echo "skipping upload to ${registry}, not logged in!" + else + case "$image" in + "jaegertracing/jaeger-opentelemetry-collector" | "jaegertracing/jaeger-opentelemetry-agent" | "jaegertracing/jaeger-opentelemetry-ingester" | "jaegertracing/opentelemetry-all-in-one" ) + docker push ${registry}/${image}:latest + ;; + *) + docker push ${registry}/${image} + ;; + esac + fi + + # upload snapshot images + if [ ! -f ${marker} ]; then + echo "skipping upload to ${registry}, not logged in!" + else + local snapshot_image="${image}-snapshot:${GITHUB_SHA}" + echo "pushing snapshot image ${snapshot_image}" + docker tag ${image} ${registry}/${snapshot_image} + docker push ${registry}/${snapshot_image} + fi +} + +main() { + check_args "$@" + + read -r tag major minor patch <<< "$(compute_image_tag ${BRANCH})" + label_release_tag $1 $2 ${major} ${minor} ${patch} + upload_images $1 $2 $3 $4 +} + +main "$@" From ac276f2b8eda264cf38e8b8c4cf3385596165569 Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Tue, 9 Feb 2021 16:02:18 +0800 Subject: [PATCH 2/9] Feedbacks Signed-off-by: Ashmita Bohara --- scripts/travis/build-all-in-one-image.sh | 8 +------- scripts/travis/build-crossdock.sh | 8 +------- scripts/travis/hotrod-integration-test.sh | 8 +------- scripts/travis/upload-all-docker-images.sh | 8 +------- scripts/travis/upload-to-registry.sh | 18 +++++++++++------- 5 files changed, 15 insertions(+), 35 deletions(-) diff --git a/scripts/travis/build-all-in-one-image.sh b/scripts/travis/build-all-in-one-image.sh index 253d5130ae1..a25e53c8633 100755 --- a/scripts/travis/build-all-in-one-image.sh +++ b/scripts/travis/build-all-in-one-image.sh @@ -35,17 +35,11 @@ run_integration_test() { } upload_to_docker() { - DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} - DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} - QUAY_USERNAME=${QUAY_USERNAME:-} - QUAY_TOKEN=${QUAY_TOKEN:-} - # Only push the docker image to dockerhub/quay.io for master/release branch if [[ "$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "upload $1 to dockerhub/quay.io" REPO=$1 - bash scripts/travis/upload-to-registry.sh "docker.io" $REPO $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN - bash scripts/travis/upload-to-registry.sh "quay.io" $REPO $QUAY_USERNAME $QUAY_TOKEN + bash scripts/travis/upload-to-registry.sh $REPO else echo 'skip docker images upload for PR' fi diff --git a/scripts/travis/build-crossdock.sh b/scripts/travis/build-crossdock.sh index 1eca4283bb1..43c20aad081 100755 --- a/scripts/travis/build-crossdock.sh +++ b/scripts/travis/build-crossdock.sh @@ -15,13 +15,7 @@ else exit 0 fi -DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} -DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} -QUAY_USERNAME=${QUAY_USERNAME:-} -QUAY_TOKEN=${QUAY_TOKEN:-} - # docker image has been build when running the crossdock REPO=jaegertracing/test-driver docker tag $REPO:latest $REPO:$COMMIT -bash scripts/travis/upload-to-registry.sh "docker.io" $REPO $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN -bash scripts/travis/upload-to-registry.sh "quay.io" $REPO $QUAY_USERNAME $QUAY_TOKEN +bash scripts/travis/upload-to-registry.sh $REPO diff --git a/scripts/travis/hotrod-integration-test.sh b/scripts/travis/hotrod-integration-test.sh index 261ca02168d..c3a3aae713b 100755 --- a/scripts/travis/hotrod-integration-test.sh +++ b/scripts/travis/hotrod-integration-test.sh @@ -27,10 +27,4 @@ else exit 0 fi -DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} -DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} -QUAY_USERNAME=${QUAY_USERNAME:-} -QUAY_TOKEN=${QUAY_TOKEN:-} - -bash scripts/travis/upload-to-registry.sh "docker.io" $REPO $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN -bash scripts/travis/upload-to-registry.sh "quay.io" $REPO $QUAY_USERNAME $QUAY_TOKEN +bash scripts/travis/upload-to-registry.sh $REPO diff --git a/scripts/travis/upload-all-docker-images.sh b/scripts/travis/upload-all-docker-images.sh index 41537ade9c0..4b6eab8e54d 100755 --- a/scripts/travis/upload-all-docker-images.sh +++ b/scripts/travis/upload-all-docker-images.sh @@ -35,14 +35,8 @@ jaeger_components=( opentelemetry-ingester ) -DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} -DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} -QUAY_USERNAME=${QUAY_USERNAME:-} -QUAY_TOKEN=${QUAY_TOKEN:-} - for component in "${jaeger_components[@]}" do REPO="jaegertracing/jaeger-${component}" - bash scripts/travis/upload-to-registry.sh "docker.io" $REPO $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN - bash scripts/travis/upload-to-registry.sh "quay.io" $REPO $QUAY_USERNAME $QUAY_TOKEN + bash scripts/travis/upload-to-registry.sh $REPO done diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh index 091b8ab81b2..019898ed641 100755 --- a/scripts/travis/upload-to-registry.sh +++ b/scripts/travis/upload-to-registry.sh @@ -3,13 +3,13 @@ set -euxf -o pipefail usage() { - echo $"Usage: $0 " + echo $"Usage: $0 " exit 1 } check_args() { - if [ ! $# -eq 4 ]; then - echo "ERROR: need exactly four arguments" + if [ ! $# -eq 1 ]; then + echo "ERROR: need exactly one argument" usage fi } @@ -58,9 +58,7 @@ try_login() { if [ ! -f ${marker} ]; then printenv ${token} | docker login ${registry} --username ${user} --password-stdin - if [ $? -eq 0 ]; then - touch ${marker} - fi + touch ${marker} fi } @@ -106,4 +104,10 @@ main() { upload_images $1 $2 $3 $4 } -main "$@" +DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} +DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} +QUAY_USERNAME=${QUAY_USERNAME:-} +QUAY_TOKEN=${QUAY_TOKEN:-} + +main "docker.io" $1 ${DOCKERHUB_USERNAME} ${DOCKERHUB_TOKEN} +main "quay.io" $1 ${QUAY_USERNAME} ${QUAY_TOKEN} From fe21cbb2550000eea5764607542ea4a93b4b03df Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Tue, 9 Feb 2021 16:46:27 +0800 Subject: [PATCH 3/9] Feedbacks Signed-off-by: Ashmita Bohara --- scripts/travis/upload-to-registry.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh index 019898ed641..d71cd6d5262 100755 --- a/scripts/travis/upload-to-registry.sh +++ b/scripts/travis/upload-to-registry.sh @@ -54,7 +54,7 @@ try_login() { local registry=$1 local user=$2 local token=$3 - local marker=.${registry}.login + local marker=$4 if [ ! -f ${marker} ]; then printenv ${token} | docker login ${registry} --username ${user} --password-stdin @@ -69,9 +69,8 @@ upload_images() { local token=$4 local marker=.${registry}.login - try_login ${registry} ${user} ${token} + try_login ${registry} ${user} ${token} ${marker} - # upload regular images if [ ! -f ${marker} ]; then echo "skipping upload to ${registry}, not logged in!" else @@ -83,12 +82,7 @@ upload_images() { docker push ${registry}/${image} ;; esac - fi - # upload snapshot images - if [ ! -f ${marker} ]; then - echo "skipping upload to ${registry}, not logged in!" - else local snapshot_image="${image}-snapshot:${GITHUB_SHA}" echo "pushing snapshot image ${snapshot_image}" docker tag ${image} ${registry}/${snapshot_image} From f6b46ae341db2fec40921c5c8f5f7b9d46198d66 Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Tue, 9 Feb 2021 22:59:54 +0800 Subject: [PATCH 4/9] Feedbacks Signed-off-by: Ashmita Bohara --- scripts/travis/upload-to-registry.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh index d71cd6d5262..faf4989ed1b 100755 --- a/scripts/travis/upload-to-registry.sh +++ b/scripts/travis/upload-to-registry.sh @@ -91,11 +91,16 @@ upload_images() { } main() { + local registry=$1 + local image=$2 + local user=$3 + local token=$4 + check_args "$@" read -r tag major minor patch <<< "$(compute_image_tag ${BRANCH})" - label_release_tag $1 $2 ${major} ${minor} ${patch} - upload_images $1 $2 $3 $4 + label_release_tag ${registry} ${image} ${major} ${minor} ${patch} + upload_images ${registry} ${image} ${user} ${token} } DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} From 0395c5b7d05964bd5b440c59527f884ef420df97 Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Wed, 10 Feb 2021 21:26:39 +0800 Subject: [PATCH 5/9] Feedbacks Signed-off-by: Ashmita Bohara --- scripts/travis/upload-to-registry.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh index faf4989ed1b..aab459dc02a 100755 --- a/scripts/travis/upload-to-registry.sh +++ b/scripts/travis/upload-to-registry.sh @@ -2,6 +2,11 @@ set -euxf -o pipefail +DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-"jaegertracingbot"} +DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} +QUAY_USERNAME=${QUAY_USERNAME:-"jaegertracingbot+github_workflows"} +QUAY_TOKEN=${QUAY_TOKEN:-} + usage() { echo $"Usage: $0 " exit 1 @@ -56,8 +61,8 @@ try_login() { local token=$3 local marker=$4 - if [ ! -f ${marker} ]; then - printenv ${token} | docker login ${registry} --username ${user} --password-stdin + if [ ! -f ${marker} && -v ${token} ]; then + printenv ${token} | docker login ${registry} --username ${user} --password-stdin touch ${marker} fi } @@ -71,7 +76,7 @@ upload_images() { try_login ${registry} ${user} ${token} ${marker} - if [ ! -f ${marker} ]; then + if [ ! -f ${marker} && -v ${token} ]; then echo "skipping upload to ${registry}, not logged in!" else case "$image" in @@ -96,17 +101,12 @@ main() { local user=$3 local token=$4 - check_args "$@" - read -r tag major minor patch <<< "$(compute_image_tag ${BRANCH})" label_release_tag ${registry} ${image} ${major} ${minor} ${patch} upload_images ${registry} ${image} ${user} ${token} } -DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-} -DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN:-} -QUAY_USERNAME=${QUAY_USERNAME:-} -QUAY_TOKEN=${QUAY_TOKEN:-} +check_args "$@" -main "docker.io" $1 ${DOCKERHUB_USERNAME} ${DOCKERHUB_TOKEN} -main "quay.io" $1 ${QUAY_USERNAME} ${QUAY_TOKEN} +main "docker.io" $1 ${DOCKERHUB_USERNAME} DOCKERHUB_TOKEN +main "quay.io" $1 ${QUAY_USERNAME} QUAY_TOKEN From 15ba2db2c21d00328753a478f9b1f33320616002 Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Wed, 10 Feb 2021 23:28:24 +0800 Subject: [PATCH 6/9] Feedbacks Signed-off-by: Ashmita Bohara --- scripts/travis/upload-to-registry.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh index aab459dc02a..153f9944838 100755 --- a/scripts/travis/upload-to-registry.sh +++ b/scripts/travis/upload-to-registry.sh @@ -61,7 +61,7 @@ try_login() { local token=$3 local marker=$4 - if [ ! -f ${marker} && -v ${token} ]; then + if [ ! -f ${marker} ] && [ -v ${token} ]; then printenv ${token} | docker login ${registry} --username ${user} --password-stdin touch ${marker} fi @@ -76,7 +76,7 @@ upload_images() { try_login ${registry} ${user} ${token} ${marker} - if [ ! -f ${marker} && -v ${token} ]; then + if [ ! -f ${marker} ] && [ -v ${token} ]; then echo "skipping upload to ${registry}, not logged in!" else case "$image" in From cf4faefa0429b2f860b1597629f35a3a3dea204e Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Wed, 10 Feb 2021 23:33:46 +0800 Subject: [PATCH 7/9] Feedbacks Signed-off-by: Ashmita Bohara --- scripts/travis/upload-to-registry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh index 153f9944838..783265ca646 100755 --- a/scripts/travis/upload-to-registry.sh +++ b/scripts/travis/upload-to-registry.sh @@ -76,7 +76,7 @@ upload_images() { try_login ${registry} ${user} ${token} ${marker} - if [ ! -f ${marker} ] && [ -v ${token} ]; then + if [ ! -f ${marker} ] && [ -z ${token} ]; then echo "skipping upload to ${registry}, not logged in!" else case "$image" in From 3b2ea2e2a742501d0ea1624533661d4bfcc91ff6 Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Thu, 11 Feb 2021 01:17:14 +0800 Subject: [PATCH 8/9] Explicitly add latest label otherwise for quay it will not work Signed-off-by: Ashmita Bohara --- scripts/travis/upload-to-registry.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh index 783265ca646..51ae3728a03 100755 --- a/scripts/travis/upload-to-registry.sh +++ b/scripts/travis/upload-to-registry.sh @@ -44,6 +44,7 @@ label_release_tag() { local minor=${4:-} local patch=${5:-} + docker tag ${image} ${registry}/${image} if [[ -n ${major} ]]; then docker tag ${image} ${registry}/${image}:${major} if [[ -n ${minor} ]]; then From 21237b7654128261a16773462128bc87c0623fbe Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Thu, 11 Feb 2021 01:32:25 +0800 Subject: [PATCH 9/9] Feedbacks Signed-off-by: Ashmita Bohara --- scripts/travis/upload-to-registry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis/upload-to-registry.sh b/scripts/travis/upload-to-registry.sh index 51ae3728a03..5c1d8226ea6 100755 --- a/scripts/travis/upload-to-registry.sh +++ b/scripts/travis/upload-to-registry.sh @@ -77,7 +77,7 @@ upload_images() { try_login ${registry} ${user} ${token} ${marker} - if [ ! -f ${marker} ] && [ -z ${token} ]; then + if [ ! -f ${marker} ]; then echo "skipping upload to ${registry}, not logged in!" else case "$image" in