Skip to content

Conversation

@ashleyshaw
Copy link
Member

@ashleyshaw ashleyshaw commented Nov 18, 2025


name: "Pull Request"
about: "General changes, refactors, and maintenance"
title: "PR: Fix metrics update workflow by handling detached HEAD and explicit checkout"
labels: ["status:needs-review"]

General Pull Request

This PR resolves a critical bug in the branding workflow where the metrics-update job failed with fatal: You are not currently on a branch due to operating in a detached HEAD state. This occurred because a prior step (which pushed changes) left the workflow without an active branch context for subsequent operations.

Key changes:

  • Explicitly set ref and fetch-depth in the actions/checkout step to ensure full branch history is available
  • Add a step to fetch the latest changes and explicitly checkout the correct branch
  • Update the push step to always specify the branch name

This ensures that the workflow jobs reliably operate on the intended branch and can perform pushes as needed.

Fixes: #branding-workflow-detached-head

This repository enforces changelog, release, and label automation for all PRs and issues.
See the Automation Governance & Release Strategy for contributor rules.

Linked issues

Closes #branding-workflow-detached-head

Changelog

Fixed

  • Ensured metrics update workflow always operates on the correct branch by performing explicit checkout and branch reference, resolving detached HEAD and failed branch pushes.

Risk Assessment

Risk Level: Low

Potential Impact:

  • Low: This affects only the workflow configuration for internal CI jobs; risk is limited to update/push steps and does not modify code deployed to production sites.

Mitigation Steps:

  • Validated workflow by running updated jobs in a branch
  • Workflow changes are reversible and limited in scope
  • Rollback possible by restoring previous workflow configuration

How to Test

Prerequisites

  • Access to repository Actions tab
  • Ability to trigger branding workflow (push or manual)

Test Steps

  1. Push changes to the branch: Ensure normal workflow completion.
  2. Verify metrics-update job: This job should checkout the correct branch, perform fetch and push operations without errors.
  3. Check Action logs: Confirm no fatal errors related to detached HEAD; verify that updates are pushed as expected.

Expected Results

  • Workflow completes without fatal: You are not currently on a branch.
  • Changes are successfully pushed to the correct branch in the metrics update step.

Edge Cases to Verify

  • Multiple successive pushes do not cause detached HEAD failures
  • Operation works on both PR and main branches

Checklist (Global DoD / PR)

  • All acceptance criteria met and demonstrated
  • Test coverage (workflow executed)
  • Docs/readme/changelog updated
  • Label and automation requirements satisfied
  • Risk assessment and testing instructions included

References

…e job

The metrics-update job was failing with "fatal: You are not currently on a branch"
because it was running in a detached HEAD state after the previous job pushed changes.

Changes:
- Add explicit ref and fetch-depth parameters to checkout action
- Add step to fetch latest changes and checkout branch explicitly
- Update push command to explicitly specify branch name

This ensures the job always operates on the correct branch and can push changes successfully.

Fixes: lightspeedwp/.github#branding-workflow-detached-head
@ashleyshaw ashleyshaw requested a review from Copilot November 18, 2025 10:56
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 18, 2025

Warning

Rate limit exceeded

@ashleyshaw has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 48 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 63e4bdb and 4d66ba3.

📒 Files selected for processing (1)
  • .github/workflows/branding.yml (2 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Note

.coderabbit.yml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'auto_labels', 'auto_assign', 'auto_review'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

The branding metrics update workflow is enhanced to handle branch-specific operations: checkout now retrieves full git history with fetch-depth: 0, a new step explicitly fetches and checks out the current branch, and the final metrics push targets the specific branch by name using {{ github.ref_name }}.

Changes

Cohort / File(s) Summary
GitHub Actions workflow enhancement
.github/workflows/branding.yml
Modified checkout step to include ref parameter and fetch-depth: 0 for full history retrieval; added "Fetch latest changes" step to explicitly fetch, checkout, and pull the current branch; updated metrics push to use specific branch name ({{ github.ref_name }}) instead of default push behavior

Sequence Diagram

sequenceDiagram
    participant GH as GitHub
    participant WF as Workflow
    
    rect rgb(230, 245, 255)
    Note over WF: Checkout phase (Updated)
    WF->>GH: Checkout with ref + fetch-depth: 0
    GH-->>WF: Full git history fetched
    end
    
    rect rgb(245, 230, 255)
    Note over WF: New branch sync phase
    WF->>GH: Fetch latest changes (explicit)
    GH-->>WF: Current branch pulled
    end
    
    rect rgb(230, 255, 245)
    Note over WF: Metrics update & push (Updated)
    WF->>WF: Update metrics
    WF->>GH: Push to {{ github.ref_name }}
    GH-->>WF: Commit pushed to branch
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single workflow file modification with parameter and step additions
  • Changes are straightforward and follow standard GitHub Actions patterns
  • Verify that the new "Fetch latest changes" step is necessary and doesn't duplicate existing checkout behavior
  • Confirm {{ github.ref_name }} correctly targets the intended branch in all contexts

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main purpose of the changes—fixing the metrics update workflow by handling detached HEAD issues and explicit checkout.
Description check ✅ Passed The PR description follows the template structure with linked issues, changelog entries, risk assessment, testing instructions, and a completed checklist.

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
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a workflow failure in the branding metrics update job caused by git operations running in a detached HEAD state. The fix adds explicit branch checkout and ensures the workflow can successfully commit and push metrics updates.

Key Changes:

  • Adds explicit ref specification to the checkout action to maintain branch context
  • Introduces a new step to fetch latest changes and explicitly checkout the branch
  • Updates the push command to specify the target branch explicitly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ashleyshaw ashleyshaw changed the title Fix branding workflow failure PR: Fix metrics update workflow by handling detached HEAD and explicit checkout Nov 18, 2025
ashleyshaw and others added 2 commits November 18, 2025 13:27
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Ash Shaw <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Ash Shaw <[email protected]>
@ashleyshaw ashleyshaw merged commit fb98704 into develop Nov 18, 2025
5 of 14 checks passed
@ashleyshaw ashleyshaw deleted the claude/fix-branding-workflow-01KNchxCdBFdg2uBAK8wiEba branch November 18, 2025 11: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.

3 participants