Skip to content

Build, Publish & Release (Bitcoin RPC Explorer) #19

Build, Publish & Release (Bitcoin RPC Explorer)

Build, Publish & Release (Bitcoin RPC Explorer) #19

name: Build, Publish & Release (Bitcoin RPC Explorer)
on:
workflow_dispatch: {}
schedule:
- cron: "23 5 * * *" # daily
concurrency:
group: btc-bitcoin-explorer
cancel-in-progress: false
env:
DOCKERHUB_REPO: magicdude4eva/btc-bitcoin-explorer
BUILD_CONTEXT: bitcoin-explorer
DOCKERFILE_PATH: bitcoin-explorer/Dockerfile
PLATFORM: linux/amd64
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write # needed to create GitHub Release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect latest explorer release tag
id: latest
run: |
set -euo pipefail
tag=$(curl -fsSL https://api.github.com/repos/janoside/btc-rpc-explorer/releases/latest \
| grep -Eo '"tag_name":\s*"[^"]+"' | sed -E 's/.*"tag_name":\s*"([^"]+)".*/\1/' )
test -n "$tag"
# derive a clean display name without leading v
name=$(printf "%s" "$tag" | sed -E 's/^v//')
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "name=$name" >> "$GITHUB_OUTPUT"
echo "Latest explorer tag: $tag (display: $name)"
- name: Skip if tag already on Docker Hub
id: hubcheck
run: |
set -euo pipefail
tag='${{ steps.latest.outputs.tag }}'
code=$(curl -s -o /dev/null -w "%{http_code}" \
"https://hub.docker.com/v2/repositories/${{ env.DOCKERHUB_REPO }}/tags/${tag}")
echo "hub_status=$code" >> "$GITHUB_OUTPUT"
if [ "$code" = "200" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Tag $tag already exists - skipping."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "Tag $tag not found - will build."
fi
- name: Set up Buildx
if: steps.hubcheck.outputs.skip == 'false'
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: steps.hubcheck.outputs.skip == 'false'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
if: steps.hubcheck.outputs.skip == 'false'
id: build
uses: docker/build-push-action@v6
with:
context: ${{ env.BUILD_CONTEXT }}
file: ${{ env.DOCKERFILE_PATH }}
platforms: ${{ env.PLATFORM }}
push: true
build-args: |
EXPLORER_REF=${{ steps.latest.outputs.tag }}
tags: |
${{ env.DOCKERHUB_REPO }}:latest
${{ env.DOCKERHUB_REPO }}:${{ steps.latest.outputs.tag }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ steps.latest.outputs.tag }}
org.opencontainers.image.title=btc-bitcoin-explorer
org.opencontainers.image.description=Bitcoin RPC Explorer - web UI for Bitcoin Core
- name: Update Docker Hub description from ./bitcoin-explorer/README.md
if: steps.hubcheck.outputs.skip == 'false'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.DOCKERHUB_REPO }}
readme-filepath: ./bitcoin-explorer/README.md
short-description: Bitcoin RPC Explorer - Web interface to interact with Bitcoin Core, optimized for Synology NAS
- name: Prepare release artifacts
if: steps.hubcheck.outputs.skip == 'false'
run: |
set -euo pipefail
echo "${{ steps.latest.outputs.tag }}" > explorer-tag.txt
echo "${{ steps.build.outputs.digest }}" > image-digest.txt
- name: Create GitHub Release in btc-fullnode-stack
if: steps.hubcheck.outputs.skip == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: explorer-${{ steps.latest.outputs.tag }}
name: Bitcoin RPC Explorer ${{ steps.latest.outputs.name }}
target_commitish: ${{ github.sha }}
generate_release_notes: true
body: |
New Explorer image published from upstream release **${{ steps.latest.outputs.tag }}**.
Docker Hub:
- https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=${{ steps.latest.outputs.tag }}
- https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=latest
Image digest:
```
${{ steps.build.outputs.digest }}
```
files: |
explorer-tag.txt
image-digest.txt
- name: Summary
run: |
echo "Explorer tag: ${{ steps.latest.outputs.tag }}"
echo "Hub status: ${{ steps.hubcheck.outputs.hub_status }}"
echo "Skipped: ${{ steps.hubcheck.outputs.skip }}"