name: 03.2. V2 AI Curator on: push: branches: - develop paths: - 'data/inventory.yaml' workflow_run: workflows: ["03.1. V2 Metadata Engine"] types: - completed workflow_dispatch: inputs: force_reevaluate: description: 'Force AI re-evaluation (ignores cache for tags/years)' type: boolean default: false restore_cache: description: 'Restore inventory from cache (Warning: May overwrite recent manual changes)' required: false type: boolean default: false permissions: contents: write pull-requests: write concurrency: group: develop-git-write-lock cancel-in-progress: false jobs: run-ai: runs-on: ubuntu-latest if: | github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' steps: - name: Repository Synchronization uses: actions/checkout@v7 with: ref: develop - name: Python 3.11 Environment Provisioning uses: actions/setup-python@v6 with: python-version: '3.11' cache: 'pip' - name: Restore Incremental Inventory Cache if: ${{ github.event.inputs.restore_cache == 'true' }} uses: actions/cache/restore@v6 with: path: data/inventory.yaml key: inventory-v2-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | inventory-v2- - name: Installation of Dependencies run: | pip install --no-cache-dir pydantic PyGithub httpx fake-useragent pytz python-dotenv pyyaml tenacity - name: Run V2 AI Curator env: GEMINI_API_KEY_1: ${{ secrets.GEMINI_API_KEY_1 }} YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} FORCE_EVAL: ${{ github.event.inputs.force_reevaluate || 'false' }} PYTHONPATH: ${{ github.workspace }} PYTHONUNBUFFERED: "1" run: python -u -m src.v2_ai - name: Commit and Push AI Analysis Updates run: | git config --global user.name "Nubenetes Bot" git config --global user.email "bot@nubenetes.com" git add data/inventory.yaml data/inventory.sql if git diff --staged --quiet; then echo "No changes in AI analysis to commit." else git commit -m "chore: update inventory AI analysis [skip ci]" # Retry rebase+push to survive concurrent bot pushes to develop. for i in {1..5}; do git pull origin develop --rebase && git push origin develop && exit 0 echo "Push attempt $i/5 rejected — retrying..."; sleep $((i * 3)) done echo "::error::Inventory AI-analysis push failed after 5 attempts."; exit 1 fi - name: Persist Incremental Inventory to Cache if: always() uses: actions/cache/save@v6 with: path: data/inventory.yaml key: inventory-v2-${{ github.run_id }}-${{ github.run_attempt }}