feat: run the generator over public FQDNs so GitHub Actions can too
readme / refresh (push) Skipped

This commit is contained in:
trex Bot committed 2026-11-19 11:57:00 -06:00
1 parent aec451d103
commit 0bd015c9a8
4 files changed
+89 -40

No files matched your search

-27
View File
@@ -61,30 +61,3 @@ jobs:
fi fi
git commit -m "chore: refresh profile README" git commit -m "chore: refresh profile README"
git push git push
# Mirrors README.md to the GitHub profile repo (jonbranan/jonbranan).
# Generation has to happen here: the Komodo and Vikunja blocks read
# 10.5.0.3, which a GitHub-hosted runner cannot reach. No-op until the
# GH_PROFILE_TOKEN secret exists.
- name: Mirror to GitHub
if: github.event_name != 'pull_request'
env:
GH_PROFILE_TOKEN: ${{ secrets.GH_PROFILE_TOKEN }}
run: |
if [ -z "$GH_PROFILE_TOKEN" ]; then
echo "GH_PROFILE_TOKEN not set - skipping GitHub mirror"
exit 0
fi
rm -rf /tmp/gh-profile
git clone --depth 1 https://github.com/jonbranan/jonbranan.git /tmp/gh-profile
cp README.md /tmp/gh-profile/README.md
cd /tmp/gh-profile
git config user.name trex
git config user.email nanobot@jonb.io
git add README.md
if git diff --cached --quiet; then
echo "GitHub README already current"
exit 0
fi
git commit -m "chore: sync profile README from git.jonb.io"
git push "https://x-access-token:${GH_PROFILE_TOKEN}@github.com/jonbranan/jonbranan.git" HEAD:main
+68
View File
@@ -0,0 +1,68 @@
name: readme
# Regenerates the self-updating blocks in README.md on GitHub.
#
# The generator is not copied here: this job clones the public Gitea repo
# (git.jonb.io/jblu/.profile) and runs tools/gen_readme.py from there, so the
# code lives in exactly one place. Every data source is reached over its public
# FQDN, so nothing internal is needed:
#
# git.jonb.io Gitea API (anonymous is enough for the public repos)
# k.jonb.io Komodo
# todo.jonb.io Vikunja
# up.jonb.io Uptime Kuma
#
# Repo secrets, both optional - a missing one keeps the previous block text:
# KOMODO_API_KEY / KOMODO_API_SECRET
# VIKUNJA_TOKEN
#
# This same file also sits in the Gitea repo, where Gitea Actions would pick it
# up; the `github.repository` guard keeps it from running there.
#
# Cron is UTC: 10:00 UTC = 04:00 CST.
on:
schedule:
- cron: "0 10 * * *"
workflow_dispatch:
push:
branches: [main]
paths:
- ".github/workflows/readme.yml"
jobs:
refresh:
if: github.repository == 'jonbranan/jonbranan'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch generator from git.jonb.io
run: git clone --depth 1 https://git.jonb.io/jblu/.profile.git /tmp/src
- name: Regenerate
env:
KOMODO_API_KEY: ${{ secrets.KOMODO_API_KEY }}
KOMODO_API_SECRET: ${{ secrets.KOMODO_API_SECRET }}
VIKUNJA_TOKEN: ${{ secrets.VIKUNJA_TOKEN }}
run: |
python3 /tmp/src/tools/gen_readme.py --write
cp /tmp/src/README.md README.md
- name: Check links are public
run: python3 /tmp/src/tools/gen_readme.py --check-links
- name: Commit
run: |
git config user.name trex
git config user.email nanobot@jonb.io
git add README.md
if git diff --cached --quiet; then
echo "no change"
exit 0
fi
git commit -m "chore: refresh profile README"
git push
+19 -11
View File
@@ -23,10 +23,15 @@ Usage:
gen_readme.py --check-links exit 1 if any link is not publicly reachable gen_readme.py --check-links exit 1 if any link is not publicly reachable
Environment: Environment:
GITEA_TOKEN required in Actions (provided per job); locally it GITEA_TOKEN optional. Set (even empty) wins; unset falls back to
falls back to ~/.config/gitea/qbit-maid-push.token ~/.config/gitea/qbit-maid-push.token. Empty means
anonymous, which is enough for the public repos.
KOMODO_API_KEY/SECRET optional; without them the stack/host counts are kept KOMODO_API_KEY/SECRET optional; without them the stack/host counts are kept
VIKUNJA_TOKEN optional; without it the completed block is kept VIKUNJA_TOKEN optional; without it the completed block is kept
Every data source is reached over its public FQDN (git.jonb.io, k.jonb.io,
todo.jonb.io, up.jonb.io), so the same script runs on the Gitea runner and on
GitHub Actions.
""" """
import argparse import argparse
@@ -64,19 +69,19 @@ def http_json(url, headers=None, data=None, timeout=25):
def gitea_token(): def gitea_token():
tok = os.environ.get("GITEA_TOKEN", "").strip() """Explicit GITEA_TOKEN wins (empty = anonymous); unset falls back to the
if tok: local token file, then to anonymous."""
return tok tok = os.environ.get("GITEA_TOKEN")
if tok is not None:
return tok.strip()
if LOCAL_TOKEN.exists(): if LOCAL_TOKEN.exists():
return LOCAL_TOKEN.read_text().strip() return LOCAL_TOKEN.read_text().strip()
raise SystemExit("no GITEA_TOKEN and no local token file") return ""
def gitea(path, tok): def gitea(path, tok):
return http_json( headers = {"Authorization": "token " + tok} if tok else {}
"https://git.jonb.io/api/v1" + path, return http_json("https://git.jonb.io/api/v1" + path, headers=headers)
headers={"Authorization": "token " + tok},
)
# ---------------------------------------------------------------- helpers # ---------------------------------------------------------------- helpers
@@ -115,7 +120,10 @@ def replace_block(text, name, body):
def previous_int(text, pattern, default=0): def previous_int(text, pattern, default=0):
m = re.search(pattern, text) # the rendered blocks wrap numbers in <span style="color:...">, so match
# against the tag-stripped text or the fallback silently yields 0
plain = re.sub(r"<[^>]+>", "", text)
m = re.search(pattern, plain)
return int(m.group(1)) if m else default return int(m.group(1)) if m else default
+2 -2
View File
@@ -121,11 +121,11 @@
"page": "homelab" "page": "homelab"
}, },
"komodo": { "komodo": {
"base": "http://10.5.0.3:9120", "base": "https://k.jonb.io",
"extra_hosts": 1 "extra_hosts": 1
}, },
"vikunja": { "vikunja": {
"base": "http://10.5.0.3:3456", "base": "https://todo.jonb.io",
"project": 2 "project": 2
}, },
"role": "technical account manager", "role": "technical account manager",