Skip to content

Conversation

@onairmarc
Copy link
Member

@onairmarc onairmarc commented Nov 6, 2025

This pull request introduces a new GitHub Action called "Enrich Pull Request" that automatically updates pull request titles and descriptions using information from branch names and Jira issues. The implementation is modular, supporting different formatting strategies, and integrates with both the GitHub and Jira APIs. The most important changes are grouped below by theme.

GitHub Action Setup and Configuration

  • Added a new Dockerfile to build and package the Go-based action for use in GitHub workflows, including a multi-stage build for a minimal image and secure execution as a non-root user.
  • Created action.yml to define the action's inputs, outputs, and runtime configuration, enabling use of custom formatting strategies and secure environment variable passing.

Core Functionality and Strategy Drivers

  • Implemented the main entrypoint in main.go, which reads environment variables, selects the formatting strategy (branch-name or jira), and orchestrates the enrichment process for pull requests.
  • Added modular drivers for branch name formatting (drivers/branch_name/branch_name.go) and Jira integration (drivers/jira/jira.go), allowing flexible enrichment based on branch naming conventions or external issue tracking. [1] [2]
  • Defined strategy constants in drivers/drivers.go for clear selection and extensibility of enrichment strategies.

GitHub and Jira API Integration

  • Implemented a comprehensive GitHub client interface in support/github/github.go to handle branch name retrieval, pull request title/description updates, label management, and custom formatting logic, including support for user-defined word exceptions.
  • Integrated Jira API access in the Jira driver, enabling retrieval of issue summaries, parent issue prefixes, and descriptions for use in pull request enrichment.

Dependency Management

  • Added a new go.mod file specifying required dependencies for GitHub and Jira API clients, as well as supporting libraries for logging and formatting.

Summary by CodeRabbit

  • New Features
    • "Enrich Pull Request" GitHub Action to auto-format PR titles and enrich PR metadata via branch-name and Jira strategies; GitHub integration for updating titles, descriptions, labels, and posting comments.
  • Improvements
    • Packaged as a multi-stage, non-root container with a defined entrypoint; added to release build matrix; optional Jira description and label sync with automatic label creation and management.
  • Documentation
    • Full usage guide, inputs, examples and troubleshooting added.

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Warning

Rate limit exceeded

@onairmarc has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fd094be and f02af8c.

📒 Files selected for processing (3)
  • actions/github/enrichPullRequest/action.yml (1 hunks)
  • actions/github/enrichPullRequest/drivers/jira/jira.go (1 hunks)
  • actions/github/enrichPullRequest/support/github/github.go (1 hunks)

Walkthrough

Adds a new enrichPullRequest GitHub Action implemented in Go: action metadata and Dockerfile, Go module and binaries, GitHub client support, branch-name and Jira formatting drivers, documentation, and a release workflow matrix entry. (49 words)

Changes

Cohort / File(s) Change Summary
Container & Action manifest
actions/github/enrichPullRequest/Dockerfile, actions/github/enrichPullRequest/action.yml, actions/github/enrichPullRequest/go.mod
New multi-stage Dockerfile building a static Go binary; action.yml defines action inputs and maps them to env vars for the container image; go.mod declares module path and dependencies.
Entrypoint
actions/github/enrichPullRequest/main.go
New main program that validates env vars, parses owner/repo and PR number, initializes the GitHub client, and dispatches to the selected formatting strategy (branch-name or jira).
Branch-name driver
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go
New driver parsing branch names with regex to extract issue key and name; adds Format(gh GitHub), GetIssueKeyFromBranchName, GetIssueNameFromBranchName; updates PR title when formatted title differs.
Jira driver
actions/github/enrichPullRequest/drivers/jira/jira.go
New Jira driver: reads Jira env vars, extracts issue key from branch, fetches issue/parent info, composes title/description, optionally ensures label exists and attaches it to the PR; introduces Configuration and Information types and Format(gh GitHub).
Driver registry
actions/github/enrichPullRequest/drivers/drivers.go
Adds strategy name constants: BranchName = "branch-name" and Jira = "jira", plus Validate(driver string) bool.
GitHub support
actions/github/enrichPullRequest/support/github/github.go
New GitHub interface and GitHubClient implementation: branch retrieval, PR info caching, title/description updates with Jira marker handling, formatting helper, label existence/creation and label attachment, and PR commenting utilities.
Release workflow matrix
.github/workflows/_release.yml
Adds actions/github/enrichPullRequest to the BuildActionImages matrix so the action image will be built and released.
Documentation
docs/Actions/GitHub/enrichPullRequest.md
New documentation describing action overview, inputs, strategies, examples, Jira integration details, required permissions, and usage examples.

Sequence Diagram(s)

sequenceDiagram
    participant Main as main
    participant GH as GitHubClient
    participant Strategy as Formatter (Branch / Jira)
    participant JiraAPI as Jira API
    participant GHAPI as GitHub API

    Main->>Main: validate env (GH_REPOSITORY, PR_NUMBER, BRANCH_NAME, OPT_FMT_STRATEGY)
    Main->>GH: New(owner, repo, prNumber)
    GH->>GHAPI: authenticate using GH_TOKEN
    Main->>Strategy: Format(gh)

    alt Branch strategy
        Strategy->>GH: GetBranchName()
        GH-->>Strategy: branch name
        Strategy->>Strategy: parse issue key/name (regex)
        Strategy->>GH: BranchNameMatchesPRTitle(current)
        alt mismatch
            Strategy->>GH: ApplyFormatting(key, name)
            GH-->>Strategy: formatted title
            GH->>GHAPI: Update PR title
        end
    else Jira strategy
        Strategy->>GH: GetBranchName()
        GH-->>Strategy: branch name
        Strategy->>Strategy: extract issue key
        Strategy->>JiraAPI: fetch issue & parent
        JiraAPI-->>Strategy: issue title/description
        alt label sync enabled
            Strategy->>GH: EnsureLabelExists(label,...)
            GH->>GHAPI: create label if missing
            GH->>GHAPI: Add label to PR
        end
        GH->>GHAPI: Update PR title & body (with Jira markers)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas to focus:
    • Regex correctness and edge cases in drivers/branch_name/branch_name.go
    • Jira client creation, authentication, and parent-issue resolution in drivers/jira/jira.go
    • PR description merging and Jira marker handling in support/github/github.go
    • Label creation/attachment flows and GitHub permission/error handling
    • Dockerfile build flags and non-root runtime configuration

Poem

🐇 I hopped through branches, found keys in their name,
parsed Jira whispers and fetched titles so tame.
I nudged PR headings and tucked markers in tight,
tied labels with care under soft moonlight,
then munched a carrot, delighted at night.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning Title contains a typo ('Encrich' instead of 'Enrich') and does not clearly convey the main purpose of the changeset. Correct the typo to read '[Actions] Create Enrich PR Action' or similar to accurately reflect that this PR introduces a new GitHub Action for enriching pull requests.
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 14

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93274f1 and 101a7bd.

⛔ Files ignored due to path filters (1)
  • actions/github/enrichPullRequest/go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • actions/github/enrichPullRequest/Dockerfile (1 hunks)
  • actions/github/enrichPullRequest/action.yml (1 hunks)
  • actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (1 hunks)
  • actions/github/enrichPullRequest/drivers/drivers.go (1 hunks)
  • actions/github/enrichPullRequest/drivers/jira/jira.go (1 hunks)
  • actions/github/enrichPullRequest/go.mod (1 hunks)
  • actions/github/enrichPullRequest/main.go (1 hunks)
  • actions/github/enrichPullRequest/support/github/github.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (2)
actions/github/enrichPullRequest/drivers/jira/jira.go (1)
  • Format (31-86)
actions/github/enrichPullRequest/support/github/github.go (1)
  • GitHub (21-31)
actions/github/enrichPullRequest/main.go (4)
actions/github/enrichPullRequest/support/github/github.go (2)
  • GitHub (21-31)
  • New (47-69)
actions/github/enrichPullRequest/drivers/drivers.go (2)
  • BranchName (3-3)
  • Jira (4-4)
actions/github/enrichPullRequest/drivers/jira/jira.go (1)
  • Format (31-86)
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (1)
  • Format (17-28)
actions/github/enrichPullRequest/drivers/jira/jira.go (2)
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (2)
  • Format (17-28)
  • GetIssueKeyFromBranchName (30-40)
actions/github/enrichPullRequest/support/github/github.go (1)
  • GitHub (21-31)
🪛 GitHub Actions: Pull Request
actions/github/enrichPullRequest/main.go

[error] 10-13: no required module provides package github.com/EncoreDigitalGroup/ci-workflows/actions/github/enrichPullRequest/drivers; to add it: go get github.com/EncoreDigitalGroup/ci-workflows/actions/github/enrichPullRequest/drivers; similarly for drivers/branch_name, drivers/jira, support/github. Also missing go.sum entry for module providing github.com/EncoreDigitalGroup/golib/logger (imported by enrichPullRequest); run 'go get' to add dependencies.

actions/github/enrichPullRequest/Dockerfile

[error] 15-17: Build failed during Go build: no required module provides package github.com/EncoreDigitalGroup/ci-workflows/actions/github/enrichPullRequest/drivers (and related subpackages) along with missing go.sum entry for golib/logger. Command: RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
actions/github/enrichPullRequest/drivers/jira/jira.go (2)

68-85: Abort enrichment when Jira payload is missing.

getJiraInfo signals failures via HasJiraInfo=false, yet we still build a [ ]-style title and push updates/labels. Return early when the Jira payload isn’t available so we never overwrite PR metadata with empty content.

     jira := getJiraInfo(config)
+    if !jira.HasJiraInfo {
+        logger.Errorf("Failed to retrieve Jira information for %s", issueKey)
+        return
+    }
 
     newPRTitle := gh.ApplyFormatting(issueKey, jira.Title)

72-74: Avoid double-wrapping Jira parent prefix.

getParentIssuePrefix already returns the prefix in brackets, so wrapping it again yields titles like [[ABC-1]]. Concatenate directly to keep the format correct.

-    if jira.ParentPrefix != "" {
-        newPRTitle = fmt.Sprintf("[%s]%s", jira.ParentPrefix, newPRTitle)
-    }
+    if jira.ParentPrefix != "" {
+        newPRTitle = fmt.Sprintf("%s%s", jira.ParentPrefix, newPRTitle)
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 101a7bd and 0d1b144.

📒 Files selected for processing (4)
  • .github/workflows/_release.yml (1 hunks)
  • actions/github/enrichPullRequest/Dockerfile (1 hunks)
  • actions/github/enrichPullRequest/action.yml (1 hunks)
  • actions/github/enrichPullRequest/drivers/jira/jira.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • actions/github/enrichPullRequest/action.yml
🧰 Additional context used
🧬 Code graph analysis (1)
actions/github/enrichPullRequest/drivers/jira/jira.go (2)
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (2)
  • Format (17-28)
  • GetIssueKeyFromBranchName (30-40)
actions/github/enrichPullRequest/support/github/github.go (1)
  • GitHub (21-31)
🪛 GitHub Actions: Pull Request
actions/github/enrichPullRequest/drivers/jira/jira.go

[error] 10-10: missing go.sum entry for module providing package github.com/ctreminiom/go-atlassian/jira/v3 (imported by github.com/EncoreDigitalGroup/ci-workflows/actions/github/enrichPullRequest/drivers/jira); to add: go get github.com/EncoreDigitalGroup/ci-workflows/actions/github/enrichPullRequest/drivers/jira


[error] 11-11: missing go.sum entry for module providing package github.com/ctreminiom/go-atlassian/pkg/infra/models (imported by github.com/EncoreDigitalGroup/ci-workflows/actions/github/enrichPullRequest/drivers/jira); to add: go get github.com/EncoreDigitalGroup/ci-workflows/actions/github/enrichPullRequest/drivers/jira

actions/github/enrichPullRequest/Dockerfile

[error] 15-15: RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . failed due to missing go.sum entries; ensure module sums are updated (e.g., 'go mod download' or 'go mod tidy')

🔇 Additional comments (4)
.github/workflows/_release.yml (1)

26-27: Matrix entry correctly formatted and properly configured.

The enrichPullRequest matrix entry is correctly structured with proper YAML formatting and naming conventions. Verification confirms:

  • Action files exist and are properly configured at actions/github/enrichPullRequest
  • action.yml specifies the correct docker image: ghcr.io/encoredigitalgroup/gh-action-enrich-pull-request:latest
  • imageName gh-action-enrich-pull-request matches the docker image reference
  • Workflow integration is correct, passing actionPath and imageName to the release workflow
actions/github/enrichPullRequest/Dockerfile (3)

12-12: ✓ Previous critical issue resolved: full source tree now copied.

The change from COPY main.go ./ to COPY . . correctly addresses the earlier reported issue where drivers and support packages were not accessible during build.


1-41: Security and build stage practices are sound.

The multi-stage build, non-root user setup, and minimal final image follow container security best practices. The alpine-based builder and final stage minimize attack surface and image size.


5-9: Original review comment is incorrect—remove this feedback.

The verification confirms that go.sum is complete (45 entries with proper hashes) and the build context is correctly configured. The CI/CD workflow runs docker build from actions/github/enrichPullRequest/, making go.mod and go.sum accessible at the build context root as expected by the COPY command. There are no missing dependencies or build configuration issues to address.

Likely an incorrect or invalid review comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
actions/github/enrichPullRequest/main.go (2)

24-28: Move environment variable initialization into main().

Package-level initialization of strategy, repo, prNumberStr, branchName, and parts executes before main() runs. While the code happens to work because checkEnvVars() validates parts before it's accessed, this initialization order makes the code fragile and harder to reason about.

Apply this diff to move initialization into main():

-// Retrieve environment variables
-var strategy = os.Getenv(envStrategy)
-var repo = os.Getenv(envGHRepository)
-var prNumberStr = os.Getenv(envPRNumber)
-var branchName = os.Getenv(envBranchName)
-var parts = strings.Split(repo, "/")
-
 // Main function to execute the program
 func main() {
+    strategy := os.Getenv(envStrategy)
+    repo := os.Getenv(envGHRepository)
+    prNumberStr := os.Getenv(envPRNumber)
+    branchName := os.Getenv(envBranchName)
+    parts := strings.Split(repo, "/")
+
-    checkEnvVars()
+    checkEnvVars(strategy, repo, prNumberStr, branchName, parts)

Then update checkEnvVars signature to accept these parameters:

-func checkEnvVars() {
+func checkEnvVars(strategy, repo, prNumberStr, branchName string, parts []string) {

44-50: Add default case for invalid strategies.

The strategy dispatch uses separate if statements with no default case. If strategy doesn't match drivers.BranchName or drivers.Jira, the program silently exits without any action or warning.

Apply this diff to use a switch with a default case:

-    if strategy == drivers.BranchName {
-        branch_name.Format(gh)
-    }
-
-    if strategy == drivers.Jira {
+    switch strategy {
+    case drivers.BranchName:
+        branch_name.Format(gh)
+    case drivers.Jira:
         jira.Format(gh)
+    default:
+        logger.Errorf("Unknown strategy: %s. Valid options are: %s, %s", strategy, drivers.BranchName, drivers.Jira)
+        os.Exit(1)
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d1b144 and b975c36.

⛔ Files ignored due to path filters (1)
  • actions/github/enrichPullRequest/go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • actions/github/enrichPullRequest/main.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
actions/github/enrichPullRequest/main.go (4)
actions/github/enrichPullRequest/support/github/github.go (2)
  • GitHub (21-31)
  • New (47-69)
actions/github/enrichPullRequest/drivers/drivers.go (2)
  • BranchName (3-3)
  • Jira (4-4)
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (1)
  • Format (17-28)
actions/github/enrichPullRequest/drivers/jira/jira.go (1)
  • Format (31-86)
🔇 Additional comments (2)
actions/github/enrichPullRequest/main.go (2)

1-14: LGTM!

Package declaration and imports are properly structured.


53-83: LGTM!

The validation logic correctly checks all required environment variables and accumulates errors before exiting, providing better user experience by reporting all missing variables at once.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
docs/Actions/GitHub/enrichPullRequest.md (3)

219-232: Add language specifiers to fenced code blocks.

These fenced code blocks lack language specifiers. While they represent branch name patterns rather than executable code, adding text or plaintext improves consistency with markdown best practices.

Apply this diff:

-```
+```text
 epic/PROJ-123-epic-title
 feature/PROJ-456-new-feature
 bugfix/PROJ-789-bug-description
 hotfix/PROJ-101-critical-fix

- +text
PROJ-123-task-description
ISSUE-456-improvement-title
TICKET-789-maintenance-task

Based on static analysis hints.


283-285: Add language specifier to fenced code block.

Add text or plaintext to maintain consistency with markdown best practices.

Apply this diff:

-```
+```text
 "key1:value1,key2:value2,key3:value3"

Based on static analysis hints.

---

`304-346`: **Use proper headings instead of bold text for subsections.**

The troubleshooting subsections use bold text instead of proper markdown headings. This affects document structure, navigation, and accessibility.



Apply this diff:

```diff
-**PR Not Updated**
+### PR Not Updated

-**Jira Connection Issues**
+### Jira Connection Issues

-**Branch Pattern Mismatch**
+### Branch Pattern Mismatch

-**Authentication Failed**
+### Authentication Failed

-**Issue Not Found**
+### Issue Not Found

-**Permission Denied**
+### Permission Denied

Based on static analysis hints.

actions/github/enrichPullRequest/main.go (1)

69-72: Consider validating repository parts are non-empty.

The validation checks that parts has exactly 2 elements, but doesn't verify that parts[0] (owner) and parts[1] (repo name) are non-empty. An input like "owner/" would pass validation but result in an empty repo name. While the GitHub API client will likely reject this, catching it here would provide clearer error messages.

Apply this diff:

     if len(parts) != 2 {
         logger.Error(envGHRepository + " must be in the format owner/repo")
         isMissingVar = true
     }
+
+    if len(parts) == 2 && (parts[0] == "" || parts[1] == "") {
+        logger.Error(envGHRepository + " must contain non-empty owner and repo names")
+        isMissingVar = true
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b95fc06 and c79a527.

📒 Files selected for processing (2)
  • actions/github/enrichPullRequest/main.go (1 hunks)
  • docs/Actions/GitHub/enrichPullRequest.md (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
actions/github/enrichPullRequest/main.go (4)
actions/github/enrichPullRequest/support/github/github.go (2)
  • GitHub (21-31)
  • New (47-69)
actions/github/enrichPullRequest/drivers/drivers.go (2)
  • BranchName (3-3)
  • Jira (4-4)
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (1)
  • Format (17-28)
actions/github/enrichPullRequest/drivers/jira/jira.go (1)
  • Format (31-86)
🪛 LanguageTool
docs/Actions/GitHub/enrichPullRequest.md

[uncategorized] ~5-~5: The official name of this software platform is spelled with a capital “H”.
Context: ...h Pull Request Action ## Overview The actions/github/enrichPullRequest action automatically...

(GITHUB)

🪛 markdownlint-cli2 (0.18.1)
docs/Actions/GitHub/enrichPullRequest.md

219-219: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


228-228: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


283-283: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


304-304: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


310-310: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


316-316: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


324-324: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


331-331: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


339-339: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
actions/github/enrichPullRequest/support/github/github.go (1)

83-96: Critical: nil dereference causes panic on API failure.

This issue was flagged in a previous review and remains unresolved. When PullRequests.Get fails on line 84, pullRequest is nil, but line 89 dereferences pullRequest.Title without checking, causing a panic.

Apply this diff to return early on error:

 func (gh *GitHubClient) BranchNameMatchesPRTitle(currentPRTitle string) bool {
     pullRequest, _, err := gh.client.PullRequests.Get(context.Background(), gh.repositoryOwner, gh.repositoryName, gh.pullRequestNumber)
     if err != nil {
-        logger.Errorf("Failed to get pullRequest request: %v", err)
+        logger.Errorf("Failed to get pull request: %v", err)
+        return false
     }
 
     if currentPRTitle == *pullRequest.Title {
🧹 Nitpick comments (3)
actions/github/enrichPullRequest/support/github/github.go (3)

128-150: Consider extracting markers as package constants.

The Jira markers are hardcoded strings. Extracting them as package-level constants would improve maintainability and allow reuse if needed elsewhere.

Additionally, the spacing logic on line 141 may produce leading/trailing double newlines when beforeJira or afterJira are empty after trimming. Consider:

const (
    jiraStartMarker = "<!-- JIRA_SYNC_START -->"
    jiraEndMarker   = "<!-- JIRA_SYNC_END -->"
)

Then in the function:

-    const jiraStartMarker = "<!-- JIRA_SYNC_START -->"
-    const jiraEndMarker = "<!-- JIRA_SYNC_END -->"

236-260: Consider distinguishing "not found" from other API errors.

The current implementation treats all GetLabel errors as "label doesn't exist" and proceeds to create it. Network errors or permission issues would also trigger label creation, which might fail and produce misleading error messages.

If desired, check for a 404 status specifically:

_, resp, err := gh.client.Issues.GetLabel(context.Background(), gh.repositoryOwner, gh.repositoryName, labelName)
if err == nil {
    // Label already exists
    return
}
// Check if it's a 404 (not found) vs other errors
if resp != nil && resp.StatusCode != 404 {
    logger.Errorf("Failed to check label '%s': %v", labelName, err)
    return
}
// Label doesn't exist, proceed to create

1-287: Consider context propagation and error returns for library reuse.

Currently, all API calls use context.Background() and most methods return void, logging errors rather than returning them. While acceptable for a GitHub Action context, these patterns limit testability and reusability:

  1. Accepting a context.Context parameter would enable cancellation and timeout control
  2. Returning errors would allow callers to implement custom error handling strategies

Example for UpdatePRTitle:

func (gh *GitHubClient) UpdatePRTitle(ctx context.Context, newPRTitle string) error {
    fmt.Println("Attempting to Update Pull Request Title to:", newPRTitle)
    
    _, _, err := gh.client.PullRequests.Edit(ctx, gh.repositoryOwner, gh.repositoryName, gh.pullRequestNumber, &github.PullRequest{
        Title: &newPRTitle,
    })
    
    if err != nil {
        logger.Errorf("Failed to update pull request title: %v", err)
        return fmt.Errorf("failed to update PR title: %w", err)
    }
    
    logger.Infof("Updated Pull Request Title to: %s", newPRTitle)
    return nil
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c79a527 and 90e8c9c.

📒 Files selected for processing (1)
  • actions/github/enrichPullRequest/support/github/github.go (1 hunks)
🔇 Additional comments (3)
actions/github/enrichPullRequest/support/github/github.go (3)

43-70: Singleton client initialization looks good.

The use of sync.Once to initialize a shared GitHub client is appropriate for this action's context, where the token remains constant throughout execution.


152-175: Good error handling with conditional success logging.

Unlike UpdatePRTitle, this function correctly uses an else block to ensure success messages are only logged when the update actually succeeds.


177-222: Exception map correctly applied.

The fix from commit 5bb1388 is properly implemented. The code now correctly splits formattedIssueName (line 213), applies exception replacements (lines 214-218), and rejoins the result (line 219) before returning.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
actions/github/enrichPullRequest/drivers/jira/jira.go (2)

76-88: Don't update the PR when Jira data is unavailable.

getJiraInfo returns HasJiraInfo=false on any fetch failure, but the code ignores this flag and proceeds to call ApplyFormatting with empty strings, producing malformed titles like [ ]. Check the flag and exit early when Jira data isn't available.

 jira := getJiraInfo(config)
+if !jira.HasJiraInfo {
+    logger.Errorf("Failed to retrieve Jira issue %s", issueKey)
+    os.Exit(1)
+}

 newPRTitle := gh.ApplyFormatting(issueKey, jira.Title)

80-82: Parent prefix is wrapped twice.

getParentIssuePrefix already returns the value wrapped in brackets (e.g., [PARENT-1] at line 134). Wrapping it again produces titles like [[PARENT-1]][ISSUE-2] .... Concatenate the prefix directly instead.

 if jira.ParentPrefix != "" {
-    newPRTitle = fmt.Sprintf("[%s]%s", jira.ParentPrefix, newPRTitle)
+    newPRTitle = fmt.Sprintf("%s%s", jira.ParentPrefix, newPRTitle)
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90e8c9c and 9ef6537.

📒 Files selected for processing (1)
  • actions/github/enrichPullRequest/drivers/jira/jira.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
actions/github/enrichPullRequest/drivers/jira/jira.go (2)
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (2)
  • Format (17-28)
  • GetIssueKeyFromBranchName (30-40)
actions/github/enrichPullRequest/support/github/github.go (1)
  • GitHub (21-32)
🔇 Additional comments (5)
actions/github/enrichPullRequest/drivers/jira/jira.go (5)

1-15: LGTM!

Package declaration and imports are well-organized. The dependencies appropriately support Jira API integration and branch name parsing.


17-30: LGTM!

Type definitions are clean and well-structured. The HasJiraInfo flag in Information provides a clear signal for error handling.


96-113: LGTM!

The Jira client creation and issue fetching helpers are straightforward with appropriate error handling and meaningful error messages.


115-176: LGTM!

The parent prefix and Jira info retrieval logic is solid. The nil check for Description at line 171 properly guards against panics when issues lack descriptions. The graceful degradation for parent prefix failures (lines 163-169) is appropriate and well-documented.


178-194: LGTM!

Environment variable helpers are cleanly implemented with case-insensitive boolean parsing and sensible defaults for the label name.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
actions/github/enrichPullRequest/support/github/github.go (1)

83-96: Critical: Nil dereference will cause panic on API error.

When PullRequests.Get fails on line 84, pullRequest is nil but execution continues to line 89 where *pullRequest.Title is dereferenced, causing a panic. Return early after logging the error.

Apply this diff:

 func (gh *GitHubClient) BranchNameMatchesPRTitle(currentPRTitle string) bool {
     pullRequest, _, err := gh.client.PullRequests.Get(context.Background(), gh.repositoryOwner, gh.repositoryName, gh.pullRequestNumber)
     if err != nil {
         logger.Errorf("Failed to get pullRequest request: %v", err)
+        return false
     }

     if currentPRTitle == *pullRequest.Title {
🧹 Nitpick comments (3)
docs/Actions/GitHub/enrichPullRequest.md (3)

222-235: Add language identifier to code blocks.

The code blocks at lines 222 and 231 are missing language identifiers, which triggers markdownlint warnings and reduces syntax highlighting support.

Apply this diff to add language identifiers:

-```
+```text
 epic/PROJ-123-epic-title
 feature/PROJ-456-new-feature
 bugfix/PROJ-789-bug-description
 hotfix/PROJ-101-critical-fix

- +text
PROJ-123-task-description
ISSUE-456-improvement-title
TICKET-789-maintenance-task


288-303: Add language identifier to format example.

The code block at line 288 is missing a language identifier, reducing clarity and triggering linting warnings.

Apply this diff:

-```
+```text
 "key1:value1,key2:value2,key3:value3"

---

`309-352`: **Use proper heading syntax instead of bold text.**

Lines 309, 315, 321, 329, 336, and 344 use bold text (`**text**`) instead of proper Markdown heading syntax (`###`), which reduces document structure and triggers markdownlint warnings.



Apply this diff to convert bold text to headings:

```diff
-**PR Not Updated**
+### PR Not Updated

-**Jira Connection Issues**
+### Jira Connection Issues

-**Branch Pattern Mismatch**
+### Branch Pattern Mismatch

-**Authentication Failed**
+### Authentication Failed

-**Issue Not Found**
+### Issue Not Found

-**Permission Denied**
+### Permission Denied
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a76c0b2 and aafacb4.

📒 Files selected for processing (5)
  • actions/github/enrichPullRequest/drivers/drivers.go (1 hunks)
  • actions/github/enrichPullRequest/drivers/jira/jira.go (1 hunks)
  • actions/github/enrichPullRequest/main.go (1 hunks)
  • actions/github/enrichPullRequest/support/github/github.go (1 hunks)
  • docs/Actions/GitHub/enrichPullRequest.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • actions/github/enrichPullRequest/drivers/drivers.go
  • actions/github/enrichPullRequest/drivers/jira/jira.go
🧰 Additional context used
🧬 Code graph analysis (1)
actions/github/enrichPullRequest/main.go (4)
actions/github/enrichPullRequest/support/github/github.go (2)
  • GitHub (21-32)
  • New (48-70)
actions/github/enrichPullRequest/drivers/drivers.go (3)
  • Validate (6-19)
  • BranchName (3-3)
  • Jira (4-4)
actions/github/enrichPullRequest/drivers/jira/jira.go (1)
  • Format (32-99)
actions/github/enrichPullRequest/drivers/branch_name/branch_name.go (1)
  • Format (17-28)
🪛 LanguageTool
docs/Actions/GitHub/enrichPullRequest.md

[uncategorized] ~5-~5: The official name of this software platform is spelled with a capital “H”.
Context: ...h Pull Request Action ## Overview The actions/github/enrichPullRequest action automatically...

(GITHUB)

🪛 markdownlint-cli2 (0.18.1)
docs/Actions/GitHub/enrichPullRequest.md

222-222: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


231-231: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


288-288: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


309-309: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


315-315: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


321-321: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


329-329: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


336-336: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


344-344: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🔇 Additional comments (1)
actions/github/enrichPullRequest/main.go (1)

1-84: LGTM! Clean entrypoint with proper validation.

The main entrypoint follows a clear and logical flow: validation → initialization → dispatch. Error handling is consistent, all environment variables are properly validated before use, and the integration with the driver and GitHub client is clean. All previously identified issues have been addressed.

@onairmarc onairmarc merged commit daf7bac into main Nov 10, 2025
5 checks passed
@onairmarc onairmarc deleted the enrich-pull-request branch November 10, 2025 19:35
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.

2 participants