Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
Greptile SummaryThis PR adds a new GitHub Actions workflow ( Issues found:
Confidence Score: 3/5Not ready to merge — the duplicate-comment bug will fire on every push and the cross-repo token gap could silently break the job. There is one clear P1 defect (no deduplication means the bot spams the PR with repeated identical comments on every push) and two P2 risks (single sync PR checked; GITHUB_TOKEN may lack access to cosmos/example). The P1 alone is enough to warrant fixes before merging. .github/workflows/check-example-sync-conflict.yml — duplicate-comment guard and token scope need addressing. Important Files Changed
Reviews (1): Last reviewed commit: "Update check-example-sync-conflict.yml" | Re-trigger Greptile |
|
|
||
| MARKER="<!-- docs-sync-conflict-check -->" | ||
|
|
||
| if [ "$OVERLAP" = "[]" ] || [ -z "$OVERLAP" ]; then | ||
| echo "No overlapping files, all clear." | ||
| # If a previous warning comment exists, update it to say all clear | ||
| EXISTING_COMMENT=$(gh api "repos/cosmos/docs/issues/$PR_NUMBER/comments" \ | ||
| --jq ".[] | select(.body | contains(\"$MARKER\")) | .id" | head -1) | ||
| if [ -n "$EXISTING_COMMENT" ]; then | ||
| gh api "repos/cosmos/docs/issues/comments/$EXISTING_COMMENT" \ | ||
| -X PATCH \ | ||
| -f body="$MARKER | ||
| ✅ **Sync conflict resolved** — no overlapping files with open sync PRs on \`cosmos/example\`." |
There was a problem hiding this comment.
Duplicate comments on every push
The workflow triggers on every synchronize event (every new commit pushed to the PR). Since there's no guard against posting duplicate comments, a PR author who pushes multiple commits while the conflict exists will receive a new warning comment each time. This can become very noisy.
A simple fix is to check whether a matching comment already exists before posting:
# Check if a conflict comment already exists
EXISTING_COMMENT=$(gh pr view "$PR_NUMBER" \
--repo cosmos/docs \
--json comments \
--jq '[.comments[].body | select(startswith("⚠️ **Potential sync conflict detected**"))] | length')
if [ "$EXISTING_COMMENT" -gt 0 ]; then
echo "Conflict comment already posted, skipping."
exit 0
fi
Alternatively, use the --edit-last flag or a match-and-update-or-create pattern to keep only one comment alive.
|
|
||
| echo "Open sync PRs: $SYNC_PRS" | ||
|
|
||
| if [ "$SYNC_PRS" = "[]" ] || [ -z "$SYNC_PRS" ]; then | ||
| echo "No open sync PRs on cosmos/example, all clear." | ||
| exit 0 |
There was a problem hiding this comment.
Only the first open sync PR is checked
--jq '.[0]' selects only the first docs-sync PR on cosmos/example. If multiple sync PRs happen to be open simultaneously (e.g., one opened by the bot and another manually), conflicts with the second PR will go undetected.
Consider iterating over all open sync PRs:
SYNC_PRS=$(gh pr list \
--repo cosmos/example \
--label "docs-sync" \
--state open \
--json number,url,headRefName)
Then loop over each entry and union the file sets before computing the overlap.
| steps: | ||
| - name: Check for conflicting sync PR on cosmos/example | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Cross-repo access using
GITHUB_TOKEN may fail if cosmos/example is private
GH_TOKEN is set to secrets.GITHUB_TOKEN, which is scoped to cosmos/docs. The docs-sync-to-example.yml workflow uses a separate fine-grained PAT for all operations against cosmos/example. If that repository is private, the gh pr list --repo cosmos/example and gh pr view --repo cosmos/example calls will fail with a 404/403, causing the entire job to fail and potentially surfacing as a broken required check on the PR.
If cosmos/example is public this is fine for read-only operations; but for consistency with the existing sync workflow and to future-proof against a visibility change, consider using the same cross-repo PAT (already available as a repo secret) for the cosmos/example queries.
Workflow for sync conflicts: