From 0bd015c9a8511d25e9f5a0018ffc69ce9c8aff34 Mon Sep 17 00:00:00 2001 From: trex Date: Thu, 19 Nov 2026 11:57:00 -0600 Subject: [PATCH] feat: run the generator over public FQDNs so GitHub Actions can too --- .gitea/workflows/readme.yml | 27 -------------- .github/workflows/readme.yml | 68 ++++++++++++++++++++++++++++++++++++ tools/gen_readme.py | 30 ++++++++++------ tools/readme.json | 4 +-- 4 files changed, 89 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/readme.yml diff --git a/.gitea/workflows/readme.yml b/.gitea/workflows/readme.yml index b5d7085..2112b2d 100644 --- a/.gitea/workflows/readme.yml +++ b/.gitea/workflows/readme.yml @@ -61,30 +61,3 @@ jobs: fi git commit -m "chore: refresh profile README" 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 diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml new file mode 100644 index 0000000..9f34426 --- /dev/null +++ b/.github/workflows/readme.yml @@ -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 diff --git a/tools/gen_readme.py b/tools/gen_readme.py index 8f02fce..c94fcfb 100644 --- a/tools/gen_readme.py +++ b/tools/gen_readme.py @@ -23,10 +23,15 @@ Usage: gen_readme.py --check-links exit 1 if any link is not publicly reachable Environment: - GITEA_TOKEN required in Actions (provided per job); locally it - falls back to ~/.config/gitea/qbit-maid-push.token + GITEA_TOKEN optional. Set (even empty) wins; unset falls back to + ~/.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 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 @@ -64,19 +69,19 @@ def http_json(url, headers=None, data=None, timeout=25): def gitea_token(): - tok = os.environ.get("GITEA_TOKEN", "").strip() - if tok: - return tok + """Explicit GITEA_TOKEN wins (empty = anonymous); unset falls back to the + local token file, then to anonymous.""" + tok = os.environ.get("GITEA_TOKEN") + if tok is not None: + return tok.strip() if LOCAL_TOKEN.exists(): return LOCAL_TOKEN.read_text().strip() - raise SystemExit("no GITEA_TOKEN and no local token file") + return "" def gitea(path, tok): - return http_json( - "https://git.jonb.io/api/v1" + path, - headers={"Authorization": "token " + tok}, - ) + headers = {"Authorization": "token " + tok} if tok else {} + return http_json("https://git.jonb.io/api/v1" + path, headers=headers) # ---------------------------------------------------------------- helpers @@ -115,7 +120,10 @@ def replace_block(text, name, body): def previous_int(text, pattern, default=0): - m = re.search(pattern, text) + # the rendered blocks wrap numbers in , 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 diff --git a/tools/readme.json b/tools/readme.json index dce043b..0192a10 100644 --- a/tools/readme.json +++ b/tools/readme.json @@ -121,11 +121,11 @@ "page": "homelab" }, "komodo": { - "base": "http://10.5.0.3:9120", + "base": "https://k.jonb.io", "extra_hosts": 1 }, "vikunja": { - "base": "http://10.5.0.3:3456", + "base": "https://todo.jonb.io", "project": 2 }, "role": "technical account manager",