From 64dfcfedb4a845654b6e2165e04c5b854907562a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 25 Aug 2026 13:55:00 +0000
Subject: [PATCH] ci: add bitcoin-dag.yml GitHub Pages repo viewer workflow
Co-authored-by: RandyMcMillan <152159+RandyMcMillan@users.noreply.github.com>
---
.github/workflows/bitcoin-dag.yml | 445 ++++++++++++++++++++++++++++++
1 file changed, 445 insertions(+)
create mode 100644 .github/workflows/bitcoin-dag.yml
diff --git a/.github/workflows/bitcoin-dag.yml b/.github/workflows/bitcoin-dag.yml
new file mode 100644
index 000000000000..745ff28c4af7
--- /dev/null
+++ b/.github/workflows/bitcoin-dag.yml
@@ -0,0 +1,445 @@
+# Copyright (c) 2023-present The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or https://opensource.org/license/mit.
+#
+# bitcoin-dag.yml
+# ---------------
+# Builds a static GitHub Pages "repo viewer" for this repository,
+# inspired by https://github.com/gnostr-org/nostr-dag.
+#
+# The generated site is published to the gh-pages branch (or the
+# repository's configured Pages source) and provides:
+# / - landing page with repo metadata
+# /git/ - repository grid (branches, tags, recent commits)
+# /git/?repo=bitcoin&branch=master&tag=...
+# - single-repo detail panel (branches, tags, commits,
+# tracked files) — no deep-link rewrites required
+
+name: Bitcoin DAG – GitHub Pages
+
+on:
+ push:
+ branches:
+ - master
+ - main
+ workflow_dispatch:
+
+permissions:
+ contents: write # needed to push to gh-pages branch
+ pages: write
+ id-token: write
+
+concurrency:
+ group: pages-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ build-pages:
+ name: Build static repo-viewer site
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0 # full history so git log works correctly
+
+ # ------------------------------------------------------------------
+ # Gather repository metadata that will be baked into the static site
+ # ------------------------------------------------------------------
+ - name: Collect repo metadata
+ id: meta
+ run: |
+ echo "REPO_NAME=${{ github.event.repository.name }}" >> "$GITHUB_ENV"
+ echo "REPO_URL=${{ github.event.repository.html_url }}" >> "$GITHUB_ENV"
+ echo "DEFAULT_BRANCH=${{ github.event.repository.default_branch }}" >> "$GITHUB_ENV"
+ echo "REPO_DESC=${{ github.event.repository.description }}" >> "$GITHUB_ENV"
+
+ # Recent commits (last 50) as JSON
+ git log -50 --pretty=format:'{"sha":"%H","short":"%h","subject":"%s","author":"%an","date":"%ad"}' \
+ --date=iso-strict | \
+ awk 'NR>1{printf ","} {print}' | \
+ sed '1s/^/[/' | \
+ awk 'END{print "]"}' > /tmp/commits.json || echo "[]" > /tmp/commits.json
+
+ # Branches
+ git branch -r --format='{"name":"%(refname:short)"}' | \
+ awk 'NR>1{printf ","} {print}' | \
+ sed '1s/^/[/' | \
+ awk 'END{print "]"}' > /tmp/branches.json || echo "[]" > /tmp/branches.json
+
+ # Tags (newest 20)
+ git tag --sort=-version:refname | head -20 | \
+ awk '{printf "%s{\"name\":\"%s\"}", (NR>1?",":""), $0} END{print ""}' | \
+ sed 's/^/[/; s/$/]/' > /tmp/tags.json || echo "[]" > /tmp/tags.json
+
+ # ------------------------------------------------------------------
+ # Build the static site under ./site/
+ # ------------------------------------------------------------------
+ - name: Build static site
+ run: |
+ set -euo pipefail
+ mkdir -p site/git site/shared
+
+ # ---- shared CSS / JS helpers --------------------------------
+ cat > site/shared/style.css << 'STYLE'
+ /* bitcoin-dag repo viewer – shared styles */
+ :root {
+ --bg: #0d1117;
+ --surface: #161b22;
+ --border: #30363d;
+ --text: #c9d1d9;
+ --muted: #8b949e;
+ --accent: #f7931a; /* Bitcoin orange */
+ --green: #3fb950;
+ --red: #f85149;
+ --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
+ }
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+ body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.6; }
+ a { color: var(--accent); text-decoration: none; }
+ a:hover { text-decoration: underline; }
+ code, pre { font-family: var(--mono); font-size: 12px; }
+ header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; align-items: center; gap: 16px; }
+ header .logo { font-size: 20px; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }
+ header nav a { color: var(--muted); margin-left: 16px; font-size: 13px; }
+ header nav a:hover { color: var(--text); text-decoration: none; }
+ .container { max-width: 1200px; margin: 0 auto; padding: 24px; }
+ .card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
+ .card h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
+ table { width: 100%; border-collapse: collapse; }
+ th { text-align: left; padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
+ td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; }
+ tr:last-child td { border-bottom: none; }
+ .badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
+ .badge-orange { background: rgba(247,147,26,.15); color: var(--accent); border: 1px solid rgba(247,147,26,.3); }
+ .badge-green { background: rgba(63,185,80,.15); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
+ .hash { font-family: var(--mono); color: var(--muted); font-size: 12px; }
+ .detail-panel { display: none; }
+ .detail-panel.active { display: block; }
+ footer { text-align: center; padding: 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); margin-top: 40px; }
+ STYLE
+
+ # ---- landing page (site/index.html) -------------------------
+ REPO_NAME="${{ github.event.repository.name }}"
+ REPO_URL="${{ github.event.repository.html_url }}"
+ REPO_DESC="${{ github.event.repository.description }}"
+ DEFAULT_BRANCH="${{ github.event.repository.default_branch }}"
+ BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
+ HEAD_SHA="$(git rev-parse HEAD)"
+ HEAD_SHORT="$(git rev-parse --short HEAD)"
+
+ cat > site/index.html << HTMLEOF
+
+
+
+
+
+
+ ${REPO_NAME} – bitcoin-dag viewer
+
+
+
+
+
+
+
+
+
Repository
+
+ Name ${REPO_NAME}
+ Description ${REPO_DESC}
+ Default branch ${DEFAULT_BRANCH}
+ HEAD ${HEAD_SHA}
+ Site built ${BUILD_DATE}
+
+
+
+
+
+
+
+
+
About this viewer
+
+ This static site is generated by the
+ bitcoin-dag.yml GitHub Actions workflow and
+ published to GitHub Pages on every push to
+ ${DEFAULT_BRANCH} .
+ Architecture inspired by
+ gnostr-org/nostr-dag :
+ a DAG-based Nostr federation consensus proof-of-concept
+ built at BTC++ Taipei 2025.
+
+
+
+
+
+ bitcoin-dag viewer · commit
+ ${HEAD_SHA} ·
+ built ${BUILD_DATE}
+
+
+
+ HTMLEOF
+
+ # ---- git viewer page (site/git/index.html) ------------------
+ # Embed the JSON blobs produced earlier directly into the page so
+ # the viewer works as a pure static file (no server-side API needed).
+ COMMITS_JSON="$(cat /tmp/commits.json)"
+ BRANCHES_JSON="$(cat /tmp/branches.json)"
+ TAGS_JSON="$(cat /tmp/tags.json)"
+
+ cat > site/git/index.html << GITEOF
+
+
+
+
+
+
+ ${REPO_NAME} – Git Viewer
+
+
+
+
+
+
+
+
+
+
+
+
Repository
+
${REPO_DESC}
+
+
+
+
+
${REPO_NAME}
+
${REPO_DESC}
+
+
+
+
+
+
+
+
← Back to grid
+
+
+
+
+
+
+
+
+
+
Recent commits
+
+
+
+ SHA
+ Subject
+ Author
+ Date
+
+
+
+
+
+
+
+
+
+
+ bitcoin-dag viewer · commit
+ ${HEAD_SHA} ·
+ built ${BUILD_DATE}
+
+
+
+
+
+ GITEOF
+
+ echo "Site built successfully."
+ echo "Files:"
+ find site -type f | sort
+
+ # ------------------------------------------------------------------
+ # Upload as a Pages artifact (works with the modern pages deployment)
+ # ------------------------------------------------------------------
+ - name: Upload Pages artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: site/
+
+ deploy:
+ name: Deploy to GitHub Pages
+ needs: build-pages
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+
+ environment:
+ name: github-pages
+ url: ${{ steps.deploy.outputs.page_url }}
+
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deploy
+ uses: actions/deploy-pages@v4