Repository navigation
131 lines (116 loc) · 4.85 KB
/
Copy pathbtc-explorer-build-publish.yml
File metadata and controls
131 lines (116 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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 }}"