name: OpenWiki Update and Auto-merge on: workflow_dispatch: schedule: - cron: "0 8 * * *" permissions: contents: write pull-requests: write concurrency: group: openwiki-update cancel-in-progress: false jobs: update: runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 with: persist-credentials: true fetch-depth: 0 - name: Set up Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: "22" - name: Install OpenWiki run: npm install --global openwiki@0.5.0 mermaid@11.16.0 jsdom@29.1.1 - name: Run OpenWiki id: openwiki continue-on-error: true run: openwiki code --update --print env: OPENWIKI_PROVIDER: openrouter OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} OPENWIKI_MODEL_ID: z-ai/glm-5.2 LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }} LANGCHAIN_PROJECT: openwiki LANGCHAIN_TRACING_V2: "true" - name: Exclude workflow changes if: ${{ !cancelled() }} run: git checkout -- .github/workflows/openwiki-update.yml - name: Remove transient OpenWiki run state if: ${{ !cancelled() }} run: rm -f -- openwiki/.run.json - name: Create OpenWiki update pull request id: create-pr if: ${{ !cancelled() }} uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: token: ${{ secrets.OPENWIKI_PR_TOKEN }} add-paths: | openwiki AGENTS.md CLAUDE.md branch: openwiki/update commit-message: "docs: update OpenWiki" title: "docs: update OpenWiki" body: | Automated OpenWiki documentation update. OpenWiki result: ${{ steps.openwiki.outcome }} When the result is `failure`, this PR intentionally preserves only the pages completed before the failure. A later successful run can update it. - name: Enable auto-merge after a successful update if: ${{ steps.openwiki.outcome == 'success' && steps.create-pr.outputs.pull-request-number != '' }} run: | [[ "$PR_NUMBER" =~ ^[0-9]+$ ]] gh pr merge --auto --squash "$PR_NUMBER" env: GH_TOKEN: ${{ secrets.OPENWIKI_PR_TOKEN }} PR_NUMBER: ${{ steps.create-pr.outputs.pull-request-number }} - name: Disable auto-merge after a failed update if: ${{ steps.openwiki.outcome == 'failure' && steps.create-pr.outputs.pull-request-number != '' }} run: | [[ "$PR_NUMBER" =~ ^[0-9]+$ ]] gh pr merge --disable-auto "$PR_NUMBER" env: GH_TOKEN: ${{ secrets.OPENWIKI_PR_TOKEN }} PR_NUMBER: ${{ steps.create-pr.outputs.pull-request-number }} - name: Propagate OpenWiki failure if: ${{ steps.openwiki.outcome == 'failure' }} run: exit 1