-
-
Notifications
You must be signed in to change notification settings - Fork 385
ci: add workflow to check generated docs are in sync on PRs #2069
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
Closed
armorbreak001
wants to merge
2
commits into
asyncapi:master
from
armorbreak001:fix/ci-check-generated-docs
+69
−0
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # This workflow verifies that generated documentation files are in sync with source code. | ||
| # If a PR modifies JSDoc comments or source files without regenerating docs, this check will fail. | ||
| name: 'Check generated docs are up to date' | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize] | ||
| branches: [master] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| check-docs: | ||
| name: 'Check generated docs sync' | ||
| runs-on: ubuntu-latest | ||
| # Skip for bot-generated PRs (docs updates, releases, CI sync) | ||
| if: > | ||
| !github.event.pull_request.draft && !( | ||
| (github.actor == 'asyncapi-bot' && ( | ||
| startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || | ||
| startsWith(github.event.pull_request.title, 'chore(release):') || | ||
| github.event.pull_request.title == 'chore: update generated docs' | ||
| )) || | ||
| (github.actor == 'asyncapi-bot-eve' && ( | ||
| startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || | ||
| startsWith(github.event.pull_request.title, 'chore(release):') | ||
| )) || | ||
| (github.actor == 'allcontributors[bot]' && | ||
| startsWith(github.event.pull_request.title, 'docs: add') | ||
| ) | ||
| ) | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Determine what node version to use | ||
| uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master | ||
| with: | ||
| node-version: ${{ vars.NODE_VERSION }} | ||
| id: lockversion | ||
|
|
||
| - name: Use Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "${{ steps.lockversion.outputs.version }}" | ||
| cache: 'npm' | ||
| cache-dependency-path: '**/package-lock.json' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Regenerate documentation assets | ||
| run: npm run generate:assets | ||
|
|
||
| - name: Check for doc differences | ||
| run: | | ||
| if git diff --exit-code --quiet -- '*.md'; then | ||
| echo "✅ All generated documentation is up to date" | ||
| else | ||
| echo "::error::Generated documentation is out of sync with source code." | ||
| echo "Please run 'npm run generate:assets' locally and commit the updated docs." | ||
| echo "" | ||
| echo "Changed files:" | ||
| git diff --name-only -- '*.md' | ||
| exit 1 | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
🌐 Web query:
GitHub Actions pull_request ready_for_review activity type💡 Result:
In GitHub Actions, the pull_request event supports multiple activity types (also called "types"), including ready_for_review. This type triggers a workflow when a draft pull request is marked as ready for review. To use it in a workflow YAML file: on: pull_request: types: [ready_for_review] By default, pull_request workflows trigger on opened, synchronize, and reopened. To include ready_for_review along with defaults for non-draft PRs and updates, combine them: on: pull_request: types: [opened, synchronize, reopened, ready_for_review] jobs: example: if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: - run: echo "Ready for review!" This is confirmed in official GitHub documentation on events that trigger workflows, which references webhook payloads, and multiple community examples. The ready_for_review corresponds to the pull_request webhook action when a draft PR is marked ready.
Citations:
ready_for_reviewpeter-evans/create-pull-request#3939🏁 Script executed:
Repository: asyncapi/generator
Length of output: 2899
Add
ready_for_reviewto trigger the check when draft PRs become ready.Draft PRs skip this check due to the job-level condition on line 16. When marked ready for review, the
ready_for_reviewevent fires, but since it's not in the trigger types (line 7), the workflow won't run until anothersynchronizeorreopenedevent occurs. Addready_for_reviewto ensure the docs sync check runs at the point the PR becomes mergeable.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents