From 7a7ecfb3038dfeab7459b5bd017b96a04cc02d44 Mon Sep 17 00:00:00 2001 From: bitdeals Date: Thu, 6 Aug 2026 12:01:13 +0000 Subject: [PATCH] ci: build and publish the image on every push to main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The registry account available on the testnet hosts is pull-only (403 on a blob upload even for an existing repository), so publishing goes the same way every other BitDeals image does: the Gitea runner builds and pushes with the CI credentials. Tags mirror the family — an immutable ., a moving , and :latest for compose and Watchtower. The version is read out of the Dockerfile ARG rather than repeated here: a tag that can disagree with the code inside is worse than no tag. --- .gitea/workflows/build.yaml | 48 +++++++++++++++++++++++++++++++++++++ README.md | 5 ++++ README.ru-RU.md | 5 ++++ 3 files changed, 58 insertions(+) create mode 100644 .gitea/workflows/build.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..ae8749b --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,48 @@ +name: Build docker image and push to registry.bitdeals.org +run-name: docker build and docker push +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + env: + COMMIT: ${{ gitea.sha }} + REGISTRY: 10.0.3.111:5000 + IMAGE: electrumx + USER: ${{ secrets.DOCKER_USERNAME }} + PASS: ${{ secrets.DOCKER_PASSWORD }} + steps: + - name: Checkout repository code + uses: actions/checkout@v6 + + # The version tag comes from the Dockerfile rather than from a second + # copy here: the ARG is what the build actually installs, and a tag that + # can disagree with the code inside is worse than no tag. + - name: Resolve the ElectrumX version from the Dockerfile + run: | + v=$(sed -n 's/^ARG ELECTRUMX_VERSION=//p' docker/Dockerfile) + test -n "$v" || { echo "ELECTRUMX_VERSION not found in docker/Dockerfile" >&2; exit 1; } + echo "VERSION=$v" >> "$GITHUB_ENV" + + # Three tags: the immutable one to deploy by, the moving version tag for + # people reading `docker images`, and :latest for Watchtower and compose. + - name: Build image + run: | + docker build . \ + --file docker/Dockerfile \ + --label "git-commit=$COMMIT" \ + --tag "${REGISTRY}/${IMAGE}:${VERSION}.${COMMIT::7}" \ + --tag "${REGISTRY}/${IMAGE}:${VERSION}" \ + --tag "${REGISTRY}/${IMAGE}:latest" + + - name: Docker login + run: docker login --username "$USER" --password "$PASS" "$REGISTRY" + + - name: Push images + run: | + docker push "${REGISTRY}/${IMAGE}:${VERSION}.${COMMIT::7}" + docker push "${REGISTRY}/${IMAGE}:${VERSION}" + docker push "${REGISTRY}/${IMAGE}:latest" diff --git a/README.md b/README.md index 305e158..16a4f85 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,11 @@ Anything after the image name is passed on to `electrumx_server`. ## build and publish +A push to `main` builds and publishes the image (`.gitea/workflows/build.yaml`), +tagging it three ways: `.` to deploy by, `` to read, and +`latest` for compose and Watchtower. By hand, when the registry credentials are +at hand: + ```sh docker build . --file docker/Dockerfile --tag registry.bitdeals.org/electrumx docker push registry.bitdeals.org/electrumx diff --git a/README.ru-RU.md b/README.ru-RU.md index ba35ba2..1305e27 100644 --- a/README.ru-RU.md +++ b/README.ru-RU.md @@ -60,6 +60,11 @@ docker run -d \ ## сборка и публикация +Пуш в `main` собирает и публикует образ (`.gitea/workflows/build.yaml`) с тремя +тегами: `<версия>.` — для развёртывания, `<версия>` — для чтения глазами, +`latest` — для compose и Watchtower. Вручную, если под рукой есть учётные данные +registry: + ```sh docker build . --file docker/Dockerfile --tag registry.bitdeals.org/electrumx docker push registry.bitdeals.org/electrumx