Skip to content

fix: VARLOCK_BRANCH returns merge ref instead of head branch in GitHub Actions PR context#566

Merged
philmillman merged 2 commits intomainfrom
copilot/fix-varlock-branch-defaults
Apr 8, 2026
Merged

fix: VARLOCK_BRANCH returns merge ref instead of head branch in GitHub Actions PR context#566
philmillman merged 2 commits intomainfrom
copilot/fix-varlock-branch-defaults

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

In GitHub Actions PR workflows, GITHUB_REF is refs/pull/123/merge — not a branch name. VARLOCK_BRANCH was resolving to this merge ref instead of the actual head branch (e.g. feat-init-infra).

Changes

  • ci-env-info/src/platforms.ts: GitHub Actions branch extractor now uses GITHUB_HEAD_REF || refToBranch(GITHUB_REF). GITHUB_HEAD_REF is set to the PR head branch name in PR contexts; empty otherwise, so push events fall back to the existing behavior.
  • ci-env-info/src/normalize.ts: refToBranch() now returns undefined for refs/pull/ refs — the existing comment already documented this intent but the implementation didn't match.
  • Tests added for both the getCiEnv GitHub Actions PR case and the VARLOCK_BRANCH builtin var in PR context.

Before / After:

# PR from `feat-init-infra` targeting `main`
VARLOCK_BRANCH=refs/pull/123/merge   # before
VARLOCK_BRANCH=feat-init-infra       # after

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: 90ea395

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@varlock/ci-env-info Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI changed the title [WIP] Fix VARLOCK_BRANCH defaults in GitHub Actions PR workflows fix: VARLOCK_BRANCH returns merge ref instead of head branch in GitHub Actions PR context Apr 8, 2026
Copilot AI requested a review from philmillman April 8, 2026 02:41
@philmillman philmillman requested a review from theoephraim April 8, 2026 02:48
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@varlock/ci-env-info@566

commit: 90ea395

@philmillman philmillman merged commit 012ed3f into main Apr 8, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: VARLOCK_BRANCH defaults to refs/pull-merge in GitHub Actions PR workflows

3 participants