name: 05.1. README Automated Sync on: push: branches: - develop paths-ignore: - 'README.md' - 'data/inventory.yaml' - 'docs/**' - 'v2-docs/**' workflow_dispatch: # Permite ejecución manual desde la pestaña Actions permissions: contents: write concurrency: group: develop-git-write-lock cancel-in-progress: false jobs: sync-readme: runs-on: ubuntu-latest if: | github.event_name == 'workflow_dispatch' || ( github.event.head_commit != null && !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, 'bot/v2-elite-sync') && !contains(github.event.head_commit.message, 'bot/knowledge-update') ) steps: - name: Repository Synchronization uses: actions/checkout@v7 with: fetch-depth: 0 # Full history for commit stats - name: Python 3.11 Environment Provisioning uses: actions/setup-python@v6 with: python-version: '3.11' - name: Install Dependencies run: | python -m pip install --upgrade pip pip install pyyaml pytz python-dotenv - name: Execute README Metric Updater run: | export PYTHONPATH=$PYTHONPATH:. python src/readme_updater.py - name: Validate README Integrity (Guardrail) run: | export PYTHONPATH=$PYTHONPATH:. python src/safety_readme.py - name: Commit and Push README Updates run: | git config --global user.name "Nubenetes Bot" git config --global user.email "bot@nubenetes.com" export PYTHONPATH=$PYTHONPATH:. # README.md is a *pure function* of the inventory, so we never need to # preserve a local README state: each attempt hard-resets to the freshest # remote tip, regenerates, commits and pushes. This eliminates the two # failure classes that previously broke this job: # 1. Dirty-tree abort — the earlier steps modify README.md, then # `git pull` aborted with "local changes would be overwritten by merge". # 2. Merge/rebase --ours/--theirs confusion under concurrent bot pushes. # A push can now only be rejected if the remote advanced between reset and # push; we simply retry from the new tip. No conflict resolution required. for i in {1..5}; do echo "README sync attempt $i/5..." git fetch origin develop git reset --hard origin/develop python src/readme_updater.py python src/safety_readme.py git add README.md if git diff --staged --quiet; then echo "README already in sync with inventory. Nothing to commit." exit 0 fi git commit -m "docs: automated README metric synchronization [skip ci]" if git push origin develop; then echo "Push succeeded on attempt $i." exit 0 fi echo "Attempt $i rejected — remote advanced, retrying from fresh tip..." sleep $((i * 3)) done echo "::error::README sync failed after 5 attempts (persistent write contention on develop)." exit 1