mirror of
https://github.com/nubenetes/awesome-kubernetes.git
synced 2026-07-13 02:10:15 +00:00
The Guardian's auto_format_file ("&"->"and" in headings, URL trailing-slash
normalization) ran on every changed .md including the generated v2-docs/, then
committed the result back to the PR branch. Because PRs land on develop while
release branches merge to master via plain git merge (no Guardian run), develop
ended up with the normalized form and master with the generator's raw form —
a perpetual cosmetic develop<->master drift that spawned recurring no-op
'Release: Agentic V2 Portal Update' PRs (e.g. #399).
v2_optimizer.py is the single source of truth for v2-docs/ formatting, so the
Guardian now skips that tree in the auto-format loop and drops it from the
auto-commit 'git add'. Hand-authored docs/ and README/inventory are unaffected.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
72 lines
2.8 KiB
YAML
72 lines
2.8 KiB
YAML
name: 07.1. PR Guardian AI
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
workflow_dispatch:
|
|
inputs:
|
|
pr_number:
|
|
description: 'PR number to analyze'
|
|
required: false
|
|
type: string
|
|
|
|
# Cancel superseded Guardian runs when a PR is updated (saves CI minutes + Gemini calls).
|
|
concurrency:
|
|
group: pr-guardian-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
agentic-presubmit:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref || github.ref }}
|
|
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
|
|
|
|
- name: Python Environment
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install Dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install --no-cache-dir pydantic PyGithub httpx fake-useragent pytz python-dotenv pyyaml tenacity
|
|
|
|
- name: Run PR Guardian Analysis
|
|
# Advisory gate: the Guardian is an AI heuristic that can misattribute
|
|
# pre-existing lines or mischaracterize a PR. It always posts its findings
|
|
# as a PR comment, but a non-zero exit must NOT show the PR as a blocking
|
|
# red ❌. continue-on-error keeps the check green while preserving the comment.
|
|
continue-on-error: true
|
|
env:
|
|
GEMINI_API_KEY_1: ${{ secrets.GEMINI_API_KEY_1 }}
|
|
GEMINI_API_KEY_2: ${{ secrets.GEMINI_API_KEY_2 }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ github.event.inputs.pr_number || github.event.pull_request.number }}
|
|
PYTHONPATH: ${{ github.workspace }}
|
|
run: |
|
|
python src/pr_guardian.py
|
|
|
|
- name: Commit Auto-Corrections
|
|
if: always() && github.event_name == 'pull_request'
|
|
run: |
|
|
git config --global user.name "nubenetes-bot"
|
|
git config --global user.email "bot@nubenetes.com"
|
|
# NOTE: v2-docs/ is deliberately excluded. It is generated by
|
|
# src/v2_optimizer.py (single source of truth); re-formatting it here
|
|
# caused a perpetual cosmetic develop<->master drift (see pr_guardian.py).
|
|
git add docs/ README.md data/inventory.yaml data/inventory.sql src/memory/
|
|
if ! git diff --cached --quiet; then
|
|
git commit -m "style(cleaner): auto-correcting formatting & URL normalization"
|
|
git push origin HEAD:${{ github.event.pull_request.head.ref }} || echo "⚠️ Push failed (likely fork permission limit)."
|
|
else
|
|
echo "No formatting changes to commit."
|
|
fi
|