From 9de188870e9f044fb52eabc35efdc6f3c163491e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Jun 2026 11:26:52 +0000 Subject: [PATCH] fix(ci): create Docker Hub repository before pushing image The release workflow's Docker push step fails with "denied: requested access to the resource is denied" because the Docker Hub repository runtimeverificationinc/komet-node does not yet exist. Docker Hub requires explicit repository creation before the first push. This adds a Docker Hub API call to create the repository if it doesn't already exist, with proper error handling and status reporting. --- .github/workflows/release.yml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0fab3a1..13b7dae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,8 +113,39 @@ jobs: run: docker run --rm ${TAG} komet-node --help - name: 'Push Docker image to Docker Hub' + env: + DOCKERHUB_USERNAME: rvdockerhub + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + DOCKERHUB_NAMESPACE: runtimeverificationinc + DOCKERHUB_REPO: komet-node run: | - echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login --username rvdockerhub --password-stdin + # Log in to Docker Hub + echo "${DOCKERHUB_PASSWORD}" | docker login --username "${DOCKERHUB_USERNAME}" --password-stdin + + # Ensure the Docker Hub repository exists (create if missing). + # Obtain a Docker Hub JWT for API access. + TOKEN=$(curl -s -H "Content-Type: application/json" \ + -X POST -d "{\"username\":\"${DOCKERHUB_USERNAME}\",\"password\":\"${DOCKERHUB_PASSWORD}\"}" \ + https://hub.docker.com/v2/users/login/ | jq -r '.token // empty') + if [ -z "${TOKEN}" ]; then + echo "::warning::Failed to obtain Docker Hub API token; skipping repo creation" + else + HTTP_CODE=$(curl -s -o /tmp/dockerhub-response.json -w "%{http_code}" \ + -H "Authorization: JWT ${TOKEN}" \ + -H "Content-Type: application/json" \ + -X POST \ + -d "{\"namespace\":\"${DOCKERHUB_NAMESPACE}\",\"name\":\"${DOCKERHUB_REPO}\",\"is_private\":false,\"description\":\"Komet Node — local Stellar testnet backed by K semantics\"}" \ + "https://hub.docker.com/v2/repositories/") + if [ "${HTTP_CODE}" = "201" ]; then + echo "Docker Hub repository created successfully" + elif [ "${HTTP_CODE}" = "409" ]; then + echo "Docker Hub repository already exists" + else + echo "::warning::Docker Hub repo creation returned HTTP ${HTTP_CODE}: $(cat /tmp/dockerhub-response.json)" + fi + fi + + # Push the image docker image push ${TAG} - name: 'On failure, delete drafted release'