|
| 1 | +name: Build, Publish & Release (Bitcoin RPC Explorer) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: {} |
| 5 | + schedule: |
| 6 | + - cron: "23 5 * * *" # daily |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: btc-bitcoin-explorer |
| 10 | + cancel-in-progress: false |
| 11 | + |
| 12 | +env: |
| 13 | + DOCKERHUB_REPO: magicdude4eva/btc-bitcoin-explorer |
| 14 | + BUILD_CONTEXT: . |
| 15 | + DOCKERFILE_PATH: bitcoin-explorer/Dockerfile |
| 16 | + PLATFORM: linux/amd64 |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-and-push: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + contents: write # needed to create GitHub Release |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Detect latest explorer release tag |
| 28 | + id: latest |
| 29 | + run: | |
| 30 | + set -euo pipefail |
| 31 | + tag=$(curl -fsSL https://api.github.com/repos/janoside/btc-rpc-explorer/releases/latest \ |
| 32 | + | grep -Eo '"tag_name":\s*"[^"]+"' | sed -E 's/.*"tag_name":\s*"([^"]+)".*/\1/' ) |
| 33 | + test -n "$tag" |
| 34 | + # derive a clean display name without leading v |
| 35 | + name=$(printf "%s" "$tag" | sed -E 's/^v//') |
| 36 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 37 | + echo "name=$name" >> "$GITHUB_OUTPUT" |
| 38 | + echo "Latest explorer tag: $tag (display: $name)" |
| 39 | +
|
| 40 | + - name: Skip if tag already on Docker Hub |
| 41 | + id: hubcheck |
| 42 | + run: | |
| 43 | + set -euo pipefail |
| 44 | + tag='${{ steps.latest.outputs.tag }}' |
| 45 | + code=$(curl -s -o /dev/null -w "%{http_code}" \ |
| 46 | + "https://hub.docker.com/v2/repositories/${{ env.DOCKERHUB_REPO }}/tags/${tag}") |
| 47 | + echo "hub_status=$code" >> "$GITHUB_OUTPUT" |
| 48 | + if [ "$code" = "200" ]; then |
| 49 | + echo "skip=true" >> "$GITHUB_OUTPUT" |
| 50 | + echo "Tag $tag already exists - skipping." |
| 51 | + else |
| 52 | + echo "skip=false" >> "$GITHUB_OUTPUT" |
| 53 | + echo "Tag $tag not found - will build." |
| 54 | + fi |
| 55 | +
|
| 56 | + - name: Set up Buildx |
| 57 | + if: steps.hubcheck.outputs.skip == 'false' |
| 58 | + uses: docker/setup-buildx-action@v3 |
| 59 | + |
| 60 | + - name: Log in to Docker Hub |
| 61 | + if: steps.hubcheck.outputs.skip == 'false' |
| 62 | + uses: docker/login-action@v3 |
| 63 | + with: |
| 64 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 65 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 66 | + |
| 67 | + - name: Build and push |
| 68 | + if: steps.hubcheck.outputs.skip == 'false' |
| 69 | + id: build |
| 70 | + uses: docker/build-push-action@v6 |
| 71 | + with: |
| 72 | + context: ${{ env.BUILD_CONTEXT }} |
| 73 | + file: ${{ env.DOCKERFILE_PATH }} |
| 74 | + platforms: ${{ env.PLATFORM }} |
| 75 | + push: true |
| 76 | + build-args: | |
| 77 | + EXPLORER_REF=${{ steps.latest.outputs.tag }} |
| 78 | + tags: | |
| 79 | + ${{ env.DOCKERHUB_REPO }}:latest |
| 80 | + ${{ env.DOCKERHUB_REPO }}:${{ steps.latest.outputs.tag }} |
| 81 | + labels: | |
| 82 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 83 | + org.opencontainers.image.version=${{ steps.latest.outputs.tag }} |
| 84 | + org.opencontainers.image.title=btc-bitcoin-explorer |
| 85 | + org.opencontainers.image.description=Bitcoin RPC Explorer - web UI for Bitcoin Core |
| 86 | +
|
| 87 | + - name: Update Docker Hub description from ./bitcoin-explorer/README.md |
| 88 | + if: steps.hubcheck.outputs.skip == 'false' |
| 89 | + uses: peter-evans/dockerhub-description@v4 |
| 90 | + with: |
| 91 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 92 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 93 | + repository: ${{ env.DOCKERHUB_REPO }} |
| 94 | + readme-filepath: ./bitcoin-explorer/README.md |
| 95 | + short-description: Bitcoin RPC Explorer - Web interface to interact with Bitcoin Core, optimized for Synology NAS |
| 96 | + |
| 97 | + - name: Prepare release artifacts |
| 98 | + if: steps.hubcheck.outputs.skip == 'false' |
| 99 | + run: | |
| 100 | + set -euo pipefail |
| 101 | + echo "${{ steps.latest.outputs.tag }}" > explorer-tag.txt |
| 102 | + echo "${{ steps.build.outputs.digest }}" > image-digest.txt |
| 103 | +
|
| 104 | + - name: Create GitHub Release in btc-fullnode-stack |
| 105 | + if: steps.hubcheck.outputs.skip == 'false' |
| 106 | + uses: softprops/action-gh-release@v2 |
| 107 | + with: |
| 108 | + tag_name: explorer-${{ steps.latest.outputs.tag }} |
| 109 | + name: Bitcoin RPC Explorer ${{ steps.latest.outputs.name }} |
| 110 | + target_commitish: ${{ github.sha }} |
| 111 | + generate_release_notes: true |
| 112 | + body: | |
| 113 | + New Explorer image published from upstream release **${{ steps.latest.outputs.tag }}**. |
| 114 | +
|
| 115 | + Docker Hub: |
| 116 | + - https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=${{ steps.latest.outputs.tag }} |
| 117 | + - https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=latest |
| 118 | +
|
| 119 | + Image digest: |
| 120 | + ``` |
| 121 | + ${{ steps.build.outputs.digest }} |
| 122 | + ``` |
| 123 | + files: | |
| 124 | + explorer-tag.txt |
| 125 | + image-digest.txt |
| 126 | +
|
| 127 | + - name: Summary |
| 128 | + run: | |
| 129 | + echo "Explorer tag: ${{ steps.latest.outputs.tag }}" |
| 130 | + echo "Hub status: ${{ steps.hubcheck.outputs.hub_status }}" |
| 131 | + echo "Skipped: ${{ steps.hubcheck.outputs.skip }}" |
0 commit comments