Build docker image and push to registry.bitdeals.org / build (push) Successful in 46s
Also re-triggers the build, which is what this commit is for right now: the first run built the image and then stopped at docker login, because the registry secrets did not exist for this repository yet. workflow_dispatch earns its place beyond that — the image content depends on ELECTRUMX_VERSION, a build argument, so a new upstream release is a reason to rebuild without a commit to point at.
52 lines
1.9 KiB
YAML
52 lines
1.9 KiB
YAML
name: Build docker image and push to registry.bitdeals.org
|
|
run-name: docker build and docker push
|
|
on:
|
|
# Manual trigger as well: the image also changes when upstream releases a new
|
|
# ElectrumX, which is a build argument here and not a commit.
|
|
workflow_dispatch:
|
|
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"
|