# Copy to .github/workflows/ax-wiki-update.yml and configure the provider
# secret required by the model selected in ax-code.json.
name: ax-wiki-update

on:
  workflow_dispatch:
  schedule:
    - cron: "23 6 * * 1"

permissions:
  contents: write
  pull-requests: write

jobs:
  update-wiki:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Install AX Code
        run: curl -fsSL https://download.ax-code.com/install | bash

      - name: Update and validate AX Wiki
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          ax-code wiki update --model openai/gpt-5-mini
          ax-code wiki lint

      - name: Open documentation pull request
        uses: peter-evans/create-pull-request@v7
        with:
          commit-message: "docs(wiki): refresh AX Wiki"
          title: "docs(wiki): refresh AX Wiki"
          body: |
            Automated native AX Wiki update. Review source citations before merging.
          branch: chore/ax-wiki-update
          delete-branch: true
          add-paths: |
            .ax-wiki/**
            AGENTS.md
