name: 04.2. Emergency V2 PR Generator on: workflow_dispatch: inputs: 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: v2-pr-only-${{ github.ref }} cancel-in-progress: false jobs: publish-v2: runs-on: ubuntu-latest steps: - name: Repository Synchronization uses: actions/checkout@v7 with: ref: develop fetch-depth: 0 - name: Python 3.11 Environment Provisioning uses: actions/setup-python@v6 with: python-version: '3.11' cache: 'pip' - name: Restore Incremental Inventory Cache (Mandate 22) 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: | python -m pip install --upgrade pip pip install --no-cache-dir pydantic PyGithub httpx fake-useragent pytz python-dotenv pyyaml tenacity - name: Assemble V2 Portal (Render Only) env: GEMINI_API_KEY_1: ${{ secrets.GEMINI_API_KEY_1 }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PYTHONPATH: . PYTHONUNBUFFERED: "1" run: | # The --render-only flag short-circuits AI logic and uses the cached inventory. python src/v2_optimizer.py --render-only if [ -f v2_safety_report.md ]; then cat v2_safety_report.md >> pr_description.md else echo "No safety report generated." > pr_description.md fi - name: Consolidate README Metrics (Integrated) env: PYTHONPATH: . run: | python src/readme_updater.py python src/safety_readme.py - name: Safety Reset for Workflow Files (Security) run: | # Ensure no self-modification happens to avoid permission rejections git checkout HEAD -- .github/workflows/ - name: Create Pull Request for V2 Elite Update id: cpr uses: peter-evans/create-pull-request@v8 with: branch: bot/v2-elite-sync-emergency base: develop title: "V2 Elite: Agentic Optimization Sync (Emergency Recovery)" body-path: pr_description.md commit-message: "feat: sync V2 elite curated edition from partial cache [skip ci]" labels: "v2-elite, agentic-sync" - name: Post Supplementary Architecture Audit (Comment) if: steps.cpr.outputs.pull-request-number != '' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }} run: | if [ -f v2_file_audit.md ]; then gh pr comment $PR_NUMBER --body-file v2_file_audit.md fi