Skip to content

feat(ci): add upstream repository dispatch trigger for doc-sync bot (#320)#515

Open
ravencore06 wants to merge 1 commit into
krkn-chaos:mainfrom
ravencore06:main
Open

feat(ci): add upstream repository dispatch trigger for doc-sync bot (#320)#515
ravencore06 wants to merge 1 commit into
krkn-chaos:mainfrom
ravencore06:main

Conversation

@ravencore06

Copy link
Copy Markdown

As part of my LFX Mentorship application for the Automated Doc Sync Bot (Issue #320), I noticed that before we even run an LLM to generate documentation, the system first needs a reliable way to know when upstream code actually changes.

Instead of jumping straight to the LLM generation script, this PR lays the CI/CD groundwork. It adds a repository_dispatch workflow that listens for upstream merges from repos like krkn, krkn-hub, and krknctl to trigger the future bot.

Furthermore, instead of relying on external Netlify webhooks, I integrated this natively with our existing architecture. It automatically triggers the neighboring .github/workflows/rebuild-docs-index.yml action using the gh CLI.

Since I recently fixed the search index build script to report skipped files in PR #439, this setup guarantees that whenever the future AI bot generates new markdown, the site's search index will automatically and cleanly rebuild using our native CI.

@netlify

netlify Bot commented May 29, 2026

Copy link
Copy Markdown

Deploy Preview for krkn-chaos ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9890b40
🔍 Latest deploy log https://app.netlify.com/projects/krkn-chaos/deploys/6a19c44b472f860008bad920
😎 Deploy Preview https://deploy-preview-515--krkn-chaos.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Add upstream repository dispatch trigger for doc-sync bot

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add repository_dispatch workflow to listen for upstream repository merges
• Trigger doc-sync bot preparation when upstream PRs merge
• Automatically invoke search index rebuild via native CI
• Establish foundation for future LLM-based documentation generation
Diagram
flowchart LR
  upstream["Upstream Repo<br/>krkn/krkn-hub/krknctl"]
  dispatch["repository_dispatch<br/>upstream_pr_merged"]
  trigger["upstream-doc-trigger.yml<br/>Workflow"]
  llm["Doc Sync Bot<br/>LLM Script"]
  rebuild["rebuild-docs-index.yml<br/>Workflow"]
  
  upstream -- "PR Merged" --> dispatch
  dispatch --> trigger
  trigger --> llm
  trigger --> rebuild

Loading

Grey Divider

File Changes

1. .github/workflows/upstream-doc-trigger.yml ✨ Enhancement +36/-0

Create upstream repository dispatch workflow

• New workflow file that listens for repository_dispatch events with type upstream_pr_merged
• Checks out website repository and identifies upstream source repository
• Includes stub for future LLM-based doc sync bot implementation
• Triggers rebuild-docs-index.yml workflow using gh CLI with GITHUB_TOKEN
• Sets appropriate permissions for contents read and actions write

.github/workflows/upstream-doc-trigger.yml


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented May 29, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (3)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Action required

1. Run Doc Sync Bot stub 📎 Requirement gap ≡ Correctness
Description
The new upstream trigger workflow does not actually evaluate documentation impact; it only echoes a
placeholder message. This fails the requirement to run an evaluation step when upstream merges
occur, so doc-sync decisions cannot be made automatically.
Code

.github/workflows/upstream-doc-trigger.yml[R25-29]

Evidence
PR Compliance ID 542695 and 542698 require a trigger followed by documentation impact evaluation.
The added workflow’s Run Doc Sync Bot (Stub) step only prints an echo message and performs no
evaluation logic.

Workflow triggers on merged PRs in upstream krkn-chaos repositories
Detects and supports common documentation-impacting change types
.github/workflows/upstream-doc-trigger.yml[25-29]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow is triggered but does not evaluate whether upstream changes require documentation updates.

## Issue Context
Compliance requires a post-merge trigger for upstream repos that includes a concrete evaluation step (not a stub) to determine doc impact.

## Fix Focus Areas
- .github/workflows/upstream-doc-trigger.yml[18-29]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. No draft PR creation 📎 Requirement gap ≡ Correctness
Description
The new workflow never creates a draft PR in krkn-chaos/website with generated documentation
changes. Without a PR creation step and a clear summary of changes, documentation updates cannot be
proposed in a reviewable way.
Code

.github/workflows/upstream-doc-trigger.yml[R25-36]

Evidence
PR Compliance ID 542696 requires automation to open a draft PR with doc updates, and 542699 requires
the PR to explain what upstream change triggered it and summarize doc changes. The workflow ends by
triggering rebuild-docs-index.yml and contains no PR creation or summary logic.

Automatically creates draft PRs in krkn-chaos/website with generated doc updates
PR output is review-friendly and explains upstream trigger and doc changes
.github/workflows/upstream-doc-trigger.yml[25-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow does not open a draft PR containing generated doc updates, nor does it produce review-friendly attribution/summary in a PR body.

## Issue Context
Compliance requires automatically proposing doc updates via a draft PR and making that PR review-friendly by linking to the upstream trigger and summarizing changed documentation.

## Fix Focus Areas
- .github/workflows/upstream-doc-trigger.yml[25-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Unrestricted dispatch trigger 🐞 Bug ⛨ Security
Description
The workflow runs for any repository_dispatch event of type upstream_pr_merged without
validating sender or client_payload.repository, so any caller who can dispatch this event can
trigger privileged CI work (including starting other workflows). This increases abuse risk and makes
future “doc sync bot” steps unsafe to add without additional guards.
Code

.github/workflows/upstream-doc-trigger.yml[R4-13]

Evidence
The new workflow is triggered solely by event type and does not validate sender/payload; it also
grants actions: write and uses gh workflow run, enabling chained workflow execution from any
successful dispatch caller. The downstream workflow it triggers runs with write permissions,
increasing blast radius if this entrypoint is abused.

.github/workflows/upstream-doc-trigger.yml[4-6]
.github/workflows/upstream-doc-trigger.yml[11-13]
.github/workflows/upstream-doc-trigger.yml[18-24]
.github/workflows/upstream-doc-trigger.yml[31-36]
.github/workflows/rebuild-docs-index.yml[3-6]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`upstream-doc-trigger.yml` accepts any `repository_dispatch` with type `upstream_pr_merged` and proceeds without validating the sender identity or ensuring the payload repo is one of the intended upstream repositories. Because this job also has `actions: write`, a dispatch caller can cause chained workflow runs.

## Issue Context
This workflow is intended to be triggered only by known upstream repos (krkn, krkn-hub, krknctl, etc.). Currently the payload is only echoed and never used to gate execution.

## Fix Focus Areas
- .github/workflows/upstream-doc-trigger.yml[4-36]

## Suggested fix
1. Add a job-level `if:` guard (or an early validation step that exits non-zero) that:
  - Fails when `github.event.client_payload.repository` is missing.
  - Allows only an explicit allowlist of upstream repositories.
  - Optionally allows only an explicit allowlist of dispatch senders (e.g., a bot user) via `github.event.sender.login`.
2. Consider splitting into two jobs so only the job that calls `gh workflow run` gets `actions: write`.

Example pattern (illustrative):
- `if: contains(fromJson('["krkn-chaos/krkn","krkn-chaos/krkn-hub","krkn-chaos/krknctl"]'), github.event.client_payload.repository)`
- Validation step using `set -euo pipefail` and emitting `::error::` on unexpected sender/repo.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. No comment refinement workflow 📎 Requirement gap ⚙ Maintainability
Description
There is no workflow trigger or automation to handle maintainer PR comments and refine/amend
generated documentation changes. This prevents the required interactive, comment-driven refinement
loop.
Code

.github/workflows/upstream-doc-trigger.yml[R4-7]

Evidence
PR Compliance ID 542700 requires maintainers to refine documentation PRs via comments. The added
workflow only triggers on repository_dispatch and contains no issue_comment (or equivalent)
trigger/logic to process PR comments.

Allows maintainers to refine the documentation PR via comments (interactive bot behavior)
.github/workflows/upstream-doc-trigger.yml[4-7]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The automation lacks any comment-based interaction mechanism (e.g., `issue_comment` trigger) to let maintainers request refinements and have the bot update the draft PR.

## Issue Context
Compliance requires an interactive bot behavior where PR comments can request adjustments and the bot applies updates.

## Fix Focus Areas
- .github/workflows/upstream-doc-trigger.yml[4-7]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Unconditional index rebuild 🐞 Bug ☼ Reliability
Description
upstream-doc-trigger.yml always triggers rebuild-docs-index.yml even when the doc-sync step
produces no documentation changes, which can spam rebuild runs and external rebuild calls. This can
create overlapping rebuild activity during bursts of upstream merges.
Code

.github/workflows/upstream-doc-trigger.yml[R31-36]

Evidence
The trigger step runs unconditionally and dispatches rebuild-docs-index.yml. The dispatched
workflow performs a rebuild POST request, so every upstream dispatch produces rebuild activity even
if nothing changed.

.github/workflows/upstream-doc-trigger.yml[31-36]
.github/workflows/rebuild-docs-index.yml[48-56]
api/server.js[322-346]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow dispatches `rebuild-docs-index.yml` unconditionally, regardless of whether any markdown/content changes were actually generated by the doc-sync step. This can lead to unnecessary rebuild runs and repeated calls to the rebuild endpoint.

## Issue Context
`rebuild-docs-index.yml` performs a POST to `/api/admin/rebuild-index`. Triggering it when there are no content changes provides no benefit and increases load.

## Fix Focus Areas
- .github/workflows/upstream-doc-trigger.yml[25-36]

## Suggested fix
1. After the doc-sync step, detect whether relevant docs changed (e.g., `git diff --quiet -- content/en` or `git status --porcelain`).
2. Only run `gh workflow run rebuild-docs-index.yml` when changes are present.
3. Add `concurrency:` to the upstream-trigger workflow (or to rebuild-docs-index) to prevent overlapping rebuilds (e.g., one at a time per repo/type).
4. Optionally pass context as an input: `gh workflow run rebuild-docs-index.yml -f reason="Upstream merge in $UPSTREAM_REPO"`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@github-actions github-actions Bot added the needs-dco Commits are missing a Signed-off-by line label May 29, 2026
Comment on lines +25 to +29
# (This is where your future LFX Mentorship LLM Python script will run)
- name: Run Doc Sync Bot (Stub)
run: |
echo "LLM Agent parses changes here and generates markdown files."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. run doc sync bot stub 📎 Requirement gap ≡ Correctness

The new upstream trigger workflow does not actually evaluate documentation impact; it only echoes a
placeholder message. This fails the requirement to run an evaluation step when upstream merges
occur, so doc-sync decisions cannot be made automatically.
Agent Prompt
## Issue description
The workflow is triggered but does not evaluate whether upstream changes require documentation updates.

## Issue Context
Compliance requires a post-merge trigger for upstream repos that includes a concrete evaluation step (not a stub) to determine doc impact.

## Fix Focus Areas
- .github/workflows/upstream-doc-trigger.yml[18-29]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +25 to +36
# (This is where your future LFX Mentorship LLM Python script will run)
- name: Run Doc Sync Bot (Stub)
run: |
echo "LLM Agent parses changes here and generates markdown files."

# Triggering the neighboring workflow directly using your CI expertise!
- name: Trigger Native Search Index Rebuild
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Triggering rebuild-docs-index.yml..."
gh workflow run rebuild-docs-index.yml

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. No draft pr creation 📎 Requirement gap ≡ Correctness

The new workflow never creates a draft PR in krkn-chaos/website with generated documentation
changes. Without a PR creation step and a clear summary of changes, documentation updates cannot be
proposed in a reviewable way.
Agent Prompt
## Issue description
The workflow does not open a draft PR containing generated doc updates, nor does it produce review-friendly attribution/summary in a PR body.

## Issue Context
Compliance requires automatically proposing doc updates via a draft PR and making that PR review-friendly by linking to the upstream trigger and summarizing changed documentation.

## Fix Focus Areas
- .github/workflows/upstream-doc-trigger.yml[25-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +4 to +13
on:
repository_dispatch:
types: [upstream_pr_merged]

jobs:
prepare-doc-sync:
runs-on: ubuntu-latest
permissions:
contents: read
actions: write

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. Unrestricted dispatch trigger 🐞 Bug ⛨ Security

The workflow runs for any repository_dispatch event of type upstream_pr_merged without
validating sender or client_payload.repository, so any caller who can dispatch this event can
trigger privileged CI work (including starting other workflows). This increases abuse risk and makes
future “doc sync bot” steps unsafe to add without additional guards.
Agent Prompt
## Issue description
`upstream-doc-trigger.yml` accepts any `repository_dispatch` with type `upstream_pr_merged` and proceeds without validating the sender identity or ensuring the payload repo is one of the intended upstream repositories. Because this job also has `actions: write`, a dispatch caller can cause chained workflow runs.

## Issue Context
This workflow is intended to be triggered only by known upstream repos (krkn, krkn-hub, krknctl, etc.). Currently the payload is only echoed and never used to gate execution.

## Fix Focus Areas
- .github/workflows/upstream-doc-trigger.yml[4-36]

## Suggested fix
1. Add a job-level `if:` guard (or an early validation step that exits non-zero) that:
   - Fails when `github.event.client_payload.repository` is missing.
   - Allows only an explicit allowlist of upstream repositories.
   - Optionally allows only an explicit allowlist of dispatch senders (e.g., a bot user) via `github.event.sender.login`.
2. Consider splitting into two jobs so only the job that calls `gh workflow run` gets `actions: write`.

Example pattern (illustrative):
- `if: contains(fromJson('["krkn-chaos/krkn","krkn-chaos/krkn-hub","krkn-chaos/krknctl"]'), github.event.client_payload.repository)`
- Validation step using `set -euo pipefail` and emitting `::error::` on unexpected sender/repo.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

ci: fix qodo security and permission issues

Signed-off-by: ravencore06 <srinidhisadhanala@gmail.com>
@github-actions github-actions Bot removed the needs-dco Commits are missing a Signed-off-by line label May 29, 2026
@ravencore06

Copy link
Copy Markdown
Author

Hello @rh-rahulshetty, @chaitanyaenr, @paigerube14, and @shahsahil264,

Here is a summary of the key enhancements introduced in this Pull Request for the Doc Sync Bot (#320):
Upstream Trigger: Implemented a repository_dispatch event to efficiently monitor upstream merges.
Native Integration: Leveraged the gh CLI to seamlessly trigger the existing rebuild-docs-index.yml action.
Automated Indexing: Integrated with the recent search index updates from PR #439 to ensure robust and clean documentation rebuilds.
Please let me know if any further refinements are required. I look forward to your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants