name: Generated metadata # Generated files travel through the same protected queue as other changes. # Keep an existing metadata PR fixed while it is being checked. A subsequent # merge or scheduled refresh picks up content accepted since it was created. on: push: branches: [main] paths: - 'LeanPool/**' - 'NOTICE.extra.yml' - 'python/lean_pool/notice.py' - 'python/lean_pool/stats.py' - '.github/workflows/notice.yml' pull_request_target: types: [closed] paths: ['README.md', 'NOTICE'] schedule: - cron: '17 * * * *' workflow_dispatch: concurrency: group: generated-metadata-main cancel-in-progress: false permissions: contents: read jobs: refresh: runs-on: ubuntu-latest name: Refresh generated metadata steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with: fetch-depth: 0 ref: main token: ${{ secrets.REBASE_TOKEN }} - uses: astral-sh/setup-uv@d0d8abe699bfb85fec6de9f7adb5ae17292296ff with: enable-cache: true - name: Install dependencies run: cd python && uv sync --locked - name: Publish one protected metadata PR env: GH_TOKEN: ${{ secrets.REBASE_TOKEN }} REPO: ${{ github.repository }} run: | set -euo pipefail existing=$(gh pr list -R "$REPO" --state open --head codex/generated-metadata --json number --jq '.[0].number // empty') if [ -n "$existing" ]; then echo "Metadata PR #$existing is already being checked; retaining its head." exit 0 fi git fetch origin main git checkout -b codex/generated-metadata origin/main (cd python && uv run python -m lean_pool.stats --repo ..) (cd python && uv run python -m lean_pool.notice --repo ..) unexpected=$(git diff --name-only | { grep -vE '^(NOTICE|README\.md)$' || true; }) if [ -n "$unexpected" ]; then echo '::error::Metadata generators changed other files.' exit 1 fi if git diff --quiet; then echo 'Generated metadata is already current.' exit 0 fi git config user.name 'github-actions[bot]' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' git add README.md NOTICE git commit -m 'Refresh generated project statistics and attribution' # The fixed branch may remain after its previous PR merged. Replace # only that completed automation branch, never main or an open PR. git push --force-with-lease origin HEAD:codex/generated-metadata gh pr create -R "$REPO" --head codex/generated-metadata --base main \ --title 'Refresh generated project statistics and attribution' \ --body 'Regenerates README statistics and NOTICE from the accepted project cards and attribution notes. No proof sources change.' gh pr merge -R "$REPO" codex/generated-metadata --squash --auto \ --match-head-commit "$(git rev-parse HEAD)"