Skip to content

fix: replace --json flag with grep for gh pr create compatibility - #4579

Merged
koladilip merged 1 commit into
developfrom
fix/gh-cli-compatibility
Aug 21, 2025
Merged

koladilip merged 1 commit into
developfrom
fix/gh-cli-compatibility

Conversation

@koladilip

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Fixed GitHub CLI compatibility issue in the prepare-for-prod-ut-deploy.yml workflow by replacing the --json flag with grep for extracting PR URLs.

What is the related Linear task?

N/A - Bug fix for workflow compatibility

Please explain the objectives of your changes below

The --json flag is not available for write operations like gh pr create in older versions of GitHub CLI, causing workflow failures. This fix ensures compatibility across different GitHub CLI versions.

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

Change: Replaced gh pr create --fill --json url --jq '.url' with gh pr create --fill | grep -o 'https://github.com/[^/]*/[^/]*/pull/[0-9]*'

Reason: The --json flag is only available for read operations (like gh release view) but not for write operations (like gh pr create) in older GitHub CLI versions.

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

N/A

Any technical or performance related pointers to consider with the change?

The new approach uses grep with regex to extract PR URLs, which is more compatible but slightly less robust than JSON parsing. However, it works reliably for GitHub PR URLs.

@coderabbitai review

@koladilip
koladilip requested a review from a team August 21, 2025 07:42
@coderabbitai

coderabbitai Bot commented Aug 21, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Chores
    • Improved production deployment workflow by updating PR URL detection for Shared, Hosted, and Dedicated environments.
    • Ensures PR links are consistently captured and exported to environment variables for reliable deployment tracking.
    • Enhances stability of automated PR creation steps, reducing workflow failures.
    • No changes to user-facing features or behavior.

Walkthrough

Updated PR URL extraction in .github/workflows/prepare-for-prod-ut-deploy.yml: switched from gh CLI JSON/JQ parsing to text-based grep extraction in three PR creation steps (Shared, Hosted, Dedicated). Environment variables (SHARED_PR_URL, HOSTED_PR_URL, DEDICATED_PR_URL) continue to be set. No other logic or control flow changes.

Changes

Cohort / File(s) Summary
Workflow PR URL extraction updates
.github/workflows/prepare-for-prod-ut-deploy.yml
Replace gh pr create --fill --json url --jq '.url' with `gh pr create --fill

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • sivashanmukh
  • utsabc
  • Jayachand

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/gh-cli-compatibility

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
.github/workflows/prepare-for-prod-ut-deploy.yml (3)

138-140: Harden PR URL extraction: add pipefail, capture stderr, select first match, and guard for empty.

The grep approach is fine for broad compatibility, but we can make it more robust and fail-fast if URL extraction doesn’t work (e.g., when gh output format changes, or no PR is created).

Apply this diff within this step:

-          PR_URL=$(gh pr create --fill | grep -o 'https://github.com/[^/]*/[^/]*/pull/[0-9]*')
-          echo "SHARED_PR_URL=$PR_URL" >> $GITHUB_ENV
+          PR_URL=$(gh pr create --fill 2>&1 | grep -oE 'https://github\.com/[^/]*/[^/]*/pull/[0-9]+' | head -n1)
+          if [[ -z "$PR_URL" ]]; then
+            echo "Failed to extract PR URL from gh pr create output" >&2
+            exit 1
+          fi
+          echo "SHARED_PR_URL=$PR_URL" >> $GITHUB_ENV

Additionally, at the top of this run block (outside the selected lines), consider enabling pipefail to ensure the step fails if any part of a pipeline fails:

set -o pipefail

Optionally, if newer gh is available at runtime, a two-step fallback increases reliability without relying on JSON for the create operation:

# After creation, resolve URL using view (read op) when available; else keep grep result
gh pr view --json url -q .url >/dev/null 2>&1 && PR_URL="$(gh pr view --json url -q .url)"

156-158: Repeat the same resilience upgrades for the Hosted PR creation step.

Mirroring the shared step makes behavior consistent and prevents silent Slack notifications with empty links if URL extraction fails.

Apply this diff:

-          PR_URL=$(gh pr create --fill | grep -o 'https://github.com/[^/]*/[^/]*/pull/[0-9]*')
-          echo "HOSTED_PR_URL=$PR_URL" >> $GITHUB_ENV
+          PR_URL=$(gh pr create --fill 2>&1 | grep -oE 'https://github\.com/[^/]*/[^/]*/pull/[0-9]+' | head -n1)
+          if [[ -z "$PR_URL" ]]; then
+            echo "Failed to extract PR URL from gh pr create output" >&2
+            exit 1
+          fi
+          echo "HOSTED_PR_URL=$PR_URL" >> $GITHUB_ENV

193-195: Apply the same robustness for the Dedicated PR creation step.

Keep the extraction logic uniform across all three PR creation sites to simplify future maintenance and debugging.

Apply this diff:

-          PR_URL=$(gh pr create --fill | grep -o 'https://github.com/[^/]*/[^/]*/pull/[0-9]*')
-          echo "DEDICATED_PR_URL=$PR_URL" >> $GITHUB_ENV
+          PR_URL=$(gh pr create --fill 2>&1 | grep -oE 'https://github\.com/[^/]*/[^/]*/pull/[0-9]+' | head -n1)
+          if [[ -z "$PR_URL" ]]; then
+            echo "Failed to extract PR URL from gh pr create output" >&2
+            exit 1
+          fi
+          echo "DEDICATED_PR_URL=$PR_URL" >> $GITHUB_ENV
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8132ec4 and dd1f23e.

📒 Files selected for processing (1)
  • .github/workflows/prepare-for-prod-ut-deploy.yml (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Code Coverage
  • GitHub Check: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Aug 21, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.81%. Comparing base (99c3e78) to head (dd1f23e).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4579   +/-   ##
========================================
  Coverage    91.81%   91.81%           
========================================
  Files          642      642           
  Lines        33930    33930           
  Branches      8041     8031   -10     
========================================
  Hits         31152    31152           
- Misses        2526     2548   +22     
+ Partials       252      230   -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@koladilip
koladilip merged commit ef4f64f into develop Aug 21, 2025
@koladilip
koladilip deleted the fix/gh-cli-compatibility branch August 21, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants