-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add a knowledge indexing generator for an LLM-friendly docs index #3453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a955827
053d694
ef5bf73
af711db
83c8587
be6a384
fce810d
d41019e
ee8e213
58ac50b
25d5594
f2295f4
08080bd
8785d2d
8badfd6
922fa03
4e38fb9
8f1cf8c
838eab7
baead09
24f1bc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,3 +52,14 @@ jobs: | |
| config-file: dev-docs/mkdocs.yml | ||
| deploy-prefix: dev | ||
| secrets: inherit | ||
|
|
||
| deploy-user-docs-knowledge-index: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may need a concurrency guard shared with other workflows operating on gh-pages, as having several workflows modifying concurrently may be a problem |
||
| # docs.jsonl/llms.txt only; api.jsonl is built by deploy-dev-docs-mike.yml instead. | ||
| needs: deploy-dev-docs-main | ||
| uses: ./.github/workflows/deploy-knowledge-index.yml | ||
| with: | ||
| action: deploy | ||
| version_label: main | ||
| skip_api: true | ||
| python-version: "3.10" | ||
| secrets: inherit | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may need a concurrency guard shared with other workflows operating on gh-pages, as having several workflows modifying concurrently may be a problem |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| name: Docs / Deploy knowledge index | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| action: | ||
| description: "Action to perform: deploy or delete." | ||
| required: true | ||
| type: string | ||
|
|
||
| version_label: | ||
| description: "Version label to deploy/delete, e.g. main or 3.0." | ||
| required: true | ||
| type: string | ||
|
|
||
| git_tag: | ||
| description: "Git tag whose deeplabcut package should be checked out before deploying. Required for deploy when version_label isn't main." | ||
| required: false | ||
| default: "" | ||
| type: string | ||
|
|
||
| skip_api: | ||
| description: "Leave api.jsonl untouched. Deploy only; a delete always concerns the API index." | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
|
|
||
| skip_docs: | ||
| description: "Leave docs.jsonl/llms.txt untouched. Deploy only; a delete never touches the user docs." | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
|
|
||
| python-version: | ||
| description: Python version used to build the knowledge index. | ||
| required: false | ||
| default: "3.10" | ||
| type: string | ||
|
|
||
| jobs: | ||
| knowledge-index: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| # Unsafe free-text inputs are read from the environment inside `run:` | ||
| # rather than spliced in as `${{ }}`. | ||
| env: | ||
| VERSION_LABEL: ${{ inputs.version_label }} | ||
| GIT_TAG: ${{ inputs.git_tag }} | ||
|
|
||
| steps: | ||
| - name: Reject unknown action | ||
| if: inputs.action != 'deploy' && inputs.action != 'delete' | ||
| shell: bash | ||
| run: | | ||
| echo "::error::Unsupported action. Expected 'deploy' or 'delete'." | ||
| exit 1 | ||
|
|
||
| - name: Require git_tag for release versions | ||
| if: inputs.action == 'deploy' && inputs.version_label != 'main' && inputs.git_tag == '' | ||
| shell: bash | ||
| run: | | ||
| echo "::error::git_tag is required when deploying a version other than main." | ||
| exit 1 | ||
|
|
||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # remove existing checkout to prevent merging a new version into it | ||
| - name: Check out tagged package source | ||
| if: inputs.action == 'deploy' && inputs.git_tag != '' | ||
| shell: bash | ||
| run: | | ||
| rm -rf deeplabcut | ||
| git checkout "$GIT_TAG" -- deeplabcut | ||
|
|
||
| - name: Resolve revision | ||
| if: inputs.action == 'deploy' | ||
| id: revision | ||
| shell: bash | ||
| run: | | ||
| if [ -n "$GIT_TAG" ]; then | ||
| echo "sha=$(git rev-parse "$GIT_TAG^{commit}")" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| version: "0.10.10" | ||
| enable-cache: true | ||
|
|
||
| # --system: setup-python provides no virtualenv to install into. | ||
| - name: Install knowledge-index dependencies | ||
| shell: bash | ||
| run: uv pip install --system --group knowledge-index | ||
|
|
||
| - name: Check out published knowledge index | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: gh-pages | ||
| path: gh-pages | ||
| sparse-checkout: | | ||
| knowledge | ||
|
|
||
| - name: Build knowledge index | ||
| if: inputs.action == 'deploy' | ||
| shell: bash | ||
| env: | ||
| REVISION: ${{ steps.revision.outputs.sha }} | ||
| run: | | ||
| mkdir -p _build/knowledge-index | ||
| if [ -d gh-pages/knowledge ]; then | ||
| cp -r gh-pages/knowledge _build/knowledge-index/ | ||
| fi | ||
| python -m tools.knowledge_indexing \ | ||
| --output _build/knowledge-index \ | ||
| --version-label "$VERSION_LABEL" \ | ||
| --revision "$REVISION" \ | ||
| ${{ inputs.skip_api && '--skip-api' || '' }} \ | ||
| ${{ inputs.skip_docs && '--skip-docs' || '' }} | ||
|
|
||
| - name: Deploy knowledge index | ||
| if: inputs.action == 'deploy' | ||
| uses: peaceiris/actions-gh-pages@v4 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: _build/knowledge-index | ||
| keep_files: true | ||
|
|
||
| - name: Delete version from knowledge index | ||
| if: inputs.action == 'delete' | ||
| shell: bash | ||
| run: | | ||
| python -m tools.knowledge_indexing --delete \ | ||
| --output gh-pages \ | ||
| --version-label "$VERSION_LABEL" | ||
|
|
||
| - name: Push deletion | ||
| if: inputs.action == 'delete' | ||
| shell: bash | ||
| working-directory: gh-pages | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add --all knowledge | ||
| if git diff --cached --quiet; then | ||
| echo "Nothing to delete." | ||
| else | ||
| git commit -m "Delete knowledge index for $VERSION_LABEL" | ||
| git push | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may need a concurrency guard shared with other workflows operating on gh-pages, as having several workflows modifying concurrently may be a problem