Fix: Auto-generate docs snippets and examples (#2139)

* fix: gitignore all the generated stuff

* debug: try fixing build

* debug: build error part ii

* debug: move more deps out of dev

* fix: lock

* debug: lockfile

* fix: make dir

* fix: ci

* fix: dir

* debug: sed

* fix: sed

* debug: allow skipping

* Revert "debug: allow skipping"

This reverts commit 88e0ff870d.

* debug: ci

* fix: corepack

* debug: dir

* debug: sed

* debug: path

* fix: rm sync docs for now

* fix: remove more stuff

* fix: rm unused stuff

* fix: rm copy:app

* chore: lint

* fix: rm prettier from boot

* fix: couple missing scripts

* feat: auto-gen examples on push to main

* debug: test on this branch

* fix: install pnpm

* fix: cd

* fix: cmd

* Auto-generate files after merge [skip ci]

* fix: only copy examples

* debug: dummy commit for examples check

* chore: regenerate examples

* fix: naming

* fix: unwind dummy

* fix: only run on main

* fix: pre commit

* fix: naming

* chore: gen, fix task pre

* feat: create pr

* feat: only push examples changes

* fix: don't run from this branch

* fix: regen lockfile

* fix: regen docs lockfile

---------

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
matt
2025-08-14 18:17:29 -05:00
committed by GitHub
parent 266fb077ac
commit 57bb24aef1
981 changed files with 2365 additions and 15287 deletions

View File

@@ -23,6 +23,9 @@ jobs:
- name: Install dependencies
working-directory: frontend/docs
run: pnpm install --frozen-lockfile
- name: Generate snippets
working-directory: frontend/snips
run: pnpm install --frozen-lockfile && pnpm generate && pnpm run copy:docs
- name: Lint
working-directory: frontend/docs
run: npm run lint:check
@@ -45,6 +48,9 @@ jobs:
- name: Install dependencies
working-directory: frontend/docs
run: pnpm install --frozen-lockfile
- name: Generate snippets
working-directory: frontend/snips
run: pnpm install --frozen-lockfile && pnpm generate && pnpm run copy:docs
- name: Build
working-directory: frontend/docs
run: npm run build

80
.github/workflows/gen-examples.yml vendored Normal file
View File

@@ -0,0 +1,80 @@
name: generate examples
on:
push:
branches: [ main ]
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '22'
- uses: pnpm/action-setup@v4
with:
version: 10
- name: Generate
working-directory: frontend/snips
run: pnpm i && pnpm generate && pnpm run copy:examples
- name: Check for changes in examples directory
id: verify-changed-files
run: |
# Check if there are any changes
if [ -n "$(git status --porcelain)" ]; then
CHANGED_FILES=$(git status --porcelain | awk '{print $2}')
NON_EXAMPLES_CHANGES=$(echo "$CHANGED_FILES" | grep -v "^examples/" || true)
if [ -n "$NON_EXAMPLES_CHANGES" ]; then
echo "Error: Changes detected outside of examples directory:"
echo "$NON_EXAMPLES_CHANGES"
echo "changed=false" >> $GITHUB_OUTPUT
exit 1
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Create branch and commit changes
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
BRANCH_NAME="regenerate-examples-${{ github.sha }}"
git checkout -b "$BRANCH_NAME"
git add examples/
git commit -m "chore: regenerate examples"
git push origin "$BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
id: create-branch
- name: Create Pull Request
if: steps.verify-changed-files.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "chore: regenerate examples" \
--body "Automated regeneration of examples from the main branch." \
--head "${{ steps.create-branch.outputs.branch_name }}" \
--base main
echo "pr_number=$(gh pr list --head ${{ steps.create-branch.outputs.branch_name }} --json number --jq '.[0].number')" >> $GITHUB_OUTPUT
id: create-pr
- name: Auto-approve and merge Pull Request
if: steps.verify-changed-files.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr review "${{ steps.create-branch.outputs.branch_name }}" --approve
gh pr merge "${{ steps.create-branch.outputs.branch_name }}" --squash

View File

@@ -37,10 +37,6 @@ jobs:
version: 9.15.4
run_install: false
- name: Install Atlas
run: |
curl -sSf https://atlasgo.sh | sh
- name: Compose
run: docker compose up -d