From e686e0b9f2848fec3a99364eebeea14dc4f70f19 Mon Sep 17 00:00:00 2001 From: Zhihua Lai Date: Thu, 11 Jun 2026 10:51:12 +0100 Subject: [PATCH] Build and push image to dockerhub --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ README.md | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06d5a70..f50aeca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: CI on: push: pull_request: + workflow_dispatch: jobs: test: @@ -31,3 +32,27 @@ jobs: run: | docker compose run --rm -T pricefeed \ node -e "const { loadConfig } = require('./src/config-loader'); const c = loadConfig(); if (!Array.isArray(c.rpc_nodes) || c.rpc_nodes.length < 3) { console.error('rpc_nodes missing or too few'); process.exit(1); } console.log('docker compose smoke test OK; account =', c.feed_steem_account);" + + docker_push: + name: Build and push image to Docker Hub + needs: [test, docker] + # Publish :latest only from master (or a manual run). Pull requests are + # skipped because they cannot access the environment secrets. + if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + environment: dockerhub + steps: + - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Build and push justyy/pricefeed:latest + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: justyy/pricefeed:latest diff --git a/README.md b/README.md index e2f70a3..ae277a6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![CI](https://github.com/DoctorLai/pricefeed/actions/workflows/ci.yml/badge.svg)](https://github.com/DoctorLai/pricefeed/actions/workflows/ci.yml) [![Node.js](https://img.shields.io/badge/node-%3E%3D18-43853d?logo=node.js&logoColor=white)](https://nodejs.org/) +[![Docker Hub](https://img.shields.io/docker/pulls/justyy/pricefeed?logo=docker&logoColor=white)](https://hub.docker.com/r/justyy/pricefeed) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) ![image](https://user-images.githubusercontent.com/1764434/173547905-6366f5eb-22dc-4327-bbda-6a4cc4cd3b96.png) @@ -116,6 +117,26 @@ $ docker run -itd \ pricefeed ``` +#### Use the prebuilt image from Docker Hub + +A prebuilt image is published to Docker Hub as +[`justyy/pricefeed`](https://hub.docker.com/r/justyy/pricefeed), so you can skip +the build step and pull it directly: + +``` +$ docker pull justyy/pricefeed:latest + +# Edit config.yaml first, then run the container +$ docker run -itd \ + --name pricefeed \ + -v $(pwd)/config.yaml:/app/config.yaml:ro \ + justyy/pricefeed:latest +``` + +The `latest` tag is rebuilt and pushed automatically by CI on every push to the +`master` branch (see the `docker_push` job in +[.github/workflows/ci.yml](.github/workflows/ci.yml)). + ### Run with Docker Compose ```