Skip to content

Commit 7a79216

Browse files
Make publish command work with private repos by adding JWT into curl headers (#13141)
* Make publish command work with private repos by adding in JWT token to headers for curl Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 5237d26 commit 7a79216

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.github/workflows/publish-command.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ jobs:
155155
SENTRY_PROJECT: airbyte-connectors
156156
- name: Publish ${{ github.event.inputs.connector }}
157157
run: |
158-
echo "$SPEC_CACHE_SERVICE_ACCOUNT_KEY" > spec_cache_key_file.json && docker login -u airbytebot -p ${DOCKER_PASSWORD}
158+
echo "$SPEC_CACHE_SERVICE_ACCOUNT_KEY" > spec_cache_key_file.json && docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
159159
./tools/integrations/manage.sh publish airbyte-integrations/${{ github.event.inputs.connector }} ${{ github.event.inputs.run-tests }} --publish_spec_to_cache
160160
id: publish
161161
env:
162+
DOCKER_USERNAME: airbytebot
162163
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
163164
# Oracle expects this variable to be set. Although usually present, this is not set by default on Github virtual runners.
164165
TZ: UTC

tools/integrations/manage.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,16 @@ cmd_publish() {
229229
docker push "$versioned_image"
230230
docker push "$latest_image"
231231
fi
232-
232+
233233
# Checking if the image was successfully registered on DockerHub
234234
# see the description of this PR to understand why this is needed https://github.com/airbytehq/airbyte/pull/11654/
235235
sleep 5
236+
237+
# To work for private repos we need a token as well
238+
DOCKER_USERNAME=${DOCKER_USERNAME:-airbytebot}
239+
DOCKER_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${DOCKER_USERNAME}'", "password": "'${DOCKER_PASSWORD}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
236240
TAG_URL="https://hub.docker.com/v2/repositories/${image_name}/tags/${image_version}"
237-
DOCKERHUB_RESPONSE_CODE=$(curl --silent --output /dev/null --write-out "%{http_code}" ${TAG_URL})
241+
DOCKERHUB_RESPONSE_CODE=$(curl --silent --output /dev/null --write-out "%{http_code}" -H "Authorization: JWT ${DOCKER_TOKEN}" ${TAG_URL})
238242
if [[ "${DOCKERHUB_RESPONSE_CODE}" == "404" ]]; then
239243
echo "Tag ${image_version} was not registered on DockerHub for image ${image_name}, please try to bump the version again." && exit 1
240244
fi

0 commit comments

Comments
 (0)