Create events from a dashboard: "+" button + two-click pick UX + shaded region #40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Regenerate Wiki | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| paths: | |
| - 'libs/**/*.m' | |
| - 'examples/**/*.m' | |
| - 'scripts/generate_wiki.py' | |
| workflow_dispatch: | |
| inputs: | |
| mode: | |
| description: 'Generation mode' | |
| type: choice | |
| options: [all, changed] | |
| default: all | |
| dry_run: | |
| description: 'Dry run (no PR)' | |
| type: boolean | |
| default: false | |
| concurrency: | |
| group: wiki-regen-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| regenerate: | |
| # On `pull_request: closed`, fire only when the PR was actually merged | |
| # (closed-without-merge would trigger otherwise). workflow_dispatch is | |
| # always allowed for manual recovery. | |
| if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| # `pull_request` events default to checking out the PR's merge ref. | |
| # We want the post-merge state of main so HEAD^ HEAD diffs the PR. | |
| ref: main | |
| fetch-depth: 2 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: pip install openai | |
| - name: Determine changed files | |
| id: changed | |
| env: | |
| INPUT_MODE: ${{ inputs.mode }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| run: | | |
| set -euo pipefail | |
| # `inputs.mode` can arrive empty (e.g. `gh workflow run` without --field), | |
| # so the workflow `default:` does not always apply. Manual dispatch | |
| # defaults to a full regen; PR-merge events scope to the PR's diff. | |
| if [ -n "${INPUT_MODE:-}" ]; then | |
| MODE="$INPUT_MODE" | |
| elif [ "$EVENT_NAME" = "workflow_dispatch" ]; then | |
| MODE="all" | |
| else | |
| MODE="changed" | |
| fi | |
| echo "mode=$MODE" >> "$GITHUB_OUTPUT" | |
| if [ "$MODE" = "all" ]; then | |
| echo "files=" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| FILES=$(git diff --name-only HEAD^ HEAD -- 'libs/**/*.m' 'examples/**/*.m' 'scripts/generate_wiki.py' | tr '\n' ' ') | |
| echo "files=$FILES" >> "$GITHUB_OUTPUT" | |
| echo "Changed files: $FILES" | |
| - name: Generate wiki (all) | |
| if: steps.changed.outputs.mode == 'all' | |
| env: | |
| OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} | |
| run: python3 scripts/generate_wiki.py --all | |
| - name: Generate wiki (changed) | |
| if: steps.changed.outputs.mode == 'changed' && steps.changed.outputs.files != '' | |
| env: | |
| OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} | |
| run: python3 scripts/generate_wiki.py --changed-files ${{ steps.changed.outputs.files }} | |
| - name: Check for wiki changes | |
| id: diff | |
| run: | | |
| if git diff --quiet wiki/; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "No wiki changes — exiting." | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Open or update PR | |
| if: steps.diff.outputs.changed == 'true' && inputs.dry_run != true | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| branch: wiki-update/${{ github.sha }} | |
| commit-message: 'docs: regenerate wiki pages' | |
| title: 'docs: regenerate wiki pages' | |
| body: | | |
| Auto-regenerated wiki pages. | |
| - Trigger: `${{ github.event_name }}` | |
| - Mode: `${{ steps.changed.outputs.mode }}` | |
| - Source commit: ${{ github.sha }} | |
| Merging this PR triggers `sync-wiki.yml`, which pushes `wiki/` to the `FastSense.wiki` repo. | |
| labels: | | |
| docs | |
| auto-generated |