Skip to content

Fix: Only regenerate Bruno collection when openapi.json content changes#187

Merged
ZogStriP merged 2 commits intomainfrom
copilot/fix-bruno-collection-regeneration
Jan 19, 2026
Merged

Fix: Only regenerate Bruno collection when openapi.json content changes#187
ZogStriP merged 2 commits intomainfrom
copilot/fix-bruno-collection-regeneration

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

The daily workflow creates PRs with 260+ line changes that are purely UID regenerations in bruno-collection.json. The @usebruno/converters package generates random UIDs on every run, triggered by any file changes detected via git status --porcelain.

Changes

  • Modified .github/workflows/update_docs.yml to check for actual content changes in openapi.json instead of checking for any dirty files

Before:

- name: Generate Bruno collection
  run: |
    if git status --porcelain | grep .; then
      npm run tobruno
    fi

After:

- name: Generate Bruno collection
  run: |
    if ! git diff --quiet openapi.json 2>/dev/null; then
      npm run tobruno
    fi

The workflow now skips Bruno regeneration when openapi.json is unchanged, preserving stable UIDs and avoiding noisy PRs.

Original prompt

Problem

The daily workflow generates unnecessary PRs that only contain UID changes in bruno-collection.json. This happens because @usebruno/converters generates random UIDs on every run, even when the underlying OpenAPI spec hasn't changed.

For example, PR #186 shows 260 additions/260 deletions, but all the changes are just UID regenerations like:

-  "uid": "vJsnOHdwdccX5pmg6Fdun",
+  "uid": "I8XgYrggKaArosK9uBfUh",

Root Cause

In .github/workflows/update_docs.yml, the "Generate Bruno collection" step runs npm run tobruno whenever git status --porcelain detects changes. But after npm run tojson, there are always changes to openapi.json (even if just formatting), which triggers Bruno regeneration with new random UIDs.

Solution

Modify the workflow to only regenerate the Bruno collection when openapi.json has actual content changes compared to the committed version, not just when files are dirty.

Change the "Generate Bruno collection" step from:

- name: Generate Bruno collection
  working-directory: discourse_api_docs
  run: |
    if git status --porcelain | grep .; then
      npm run tobruno
    fi

To:

- name: Generate Bruno collection
  working-directory: discourse_api_docs
  run: |
    if ! git diff --quiet openapi.json 2>/dev/null; then
      npm run tobruno
    fi

This uses git diff --quiet openapi.json which:

  1. Returns exit code 1 (triggering the if block) only if there are actual content differences in openapi.json
  2. Returns exit code 0 (skipping regeneration) if openapi.json is unchanged or only has whitespace/formatting changes that git detects as identical
  3. The 2>/dev/null handles the case where the file doesn't exist yet

This way, the Bruno collection (with its stable UIDs) is only regenerated when the OpenAPI spec actually changes, avoiding noisy PRs with only UID churn.

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: ZogStriP <362783+ZogStriP@users.noreply.github.com>
@ZogStriP ZogStriP marked this pull request as ready for review January 19, 2026 08:41
Copilot AI changed the title [WIP] Fix unnecessary UID changes in Bruno collection generation Fix: Only regenerate Bruno collection when openapi.json content changes Jan 19, 2026
Copilot AI requested a review from ZogStriP January 19, 2026 08:41
@jjaffeux jjaffeux requested a review from cvx January 19, 2026 09:26
@ZogStriP ZogStriP merged commit 1a08e73 into main Jan 19, 2026
1 check passed
@ZogStriP ZogStriP deleted the copilot/fix-bruno-collection-regeneration branch January 19, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants