Files
.profile/.gitea/workflows

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