name: readme
# Regenerates the self-updating blocks in README.md.
#
# The generator lives in tools/gen_readme.py and is stdlib-only, so there is
# nothing to install. Auth is the built-in per-job GITEA_TOKEN (write on this
# repo's contents, read-only on public repos) - no personal access token.
#
# Optional repo secrets, both degrade gracefully when absent:
# KOMODO_API_KEY / KOMODO_API_SECRET live stack + host counts
# VIKUNJA_TOKEN recently completed homelab tasks
#
# Cron is UTC: 10:00 UTC = 04:00 CST.
on:
schedule:
- cron: "0 10 * * *"
workflow_dispatch:
push:
branches: [main]
paths:
- "tools/**"
- ".gitea/workflows/readme.yml"
pull_request:
paths:
- "tools/**"
- "README.md"
- ".gitea/workflows/readme.yml"
jobs:
refresh:
# a bot commit must not re-trigger the job
if: github.event_name != 'push' || github.actor != 'trex'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Regenerate
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
KOMODO_API_KEY: ${{ secrets.KOMODO_API_KEY }}
KOMODO_API_SECRET: ${{ secrets.KOMODO_API_SECRET }}
VIKUNJA_TOKEN: ${{ secrets.VIKUNJA_TOKEN }}
run: python3 tools/gen_readme.py --write
- name: Check links are public
run: python3 tools/gen_readme.py --check-links
- name: Commit
if: github.event_name != 'pull_request'
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
# 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