Skip to content

Read defaultBase from nx.json instead of hardcoding 'main' #206

@ddeboer

Description

@ddeboer

Problem

The nx-set-shas action defaults main-branch-name to main, but Nx itself supports configuring the default base branch via defaultBase in nx.json:

{
  "defaultBase": "master"
}

This means users with repositories that use master (or any other branch) need to duplicate this configuration in both nx.json and the action's with block:

- uses: nrwl/nx-set-shas@v4
  with:
    main-branch-name: master  # duplicates nx.json defaultBase

Suggestion

The action could read nx.json and use defaultBase as the default value for main-branch-name, falling back to main only if neither is specified.

This would:

  1. Reduce configuration duplication
  2. Keep the source of truth in one place (nx.json)
  3. Be more consistent with how Nx itself behaves locally

Context

When the action can't find a successful workflow on the configured branch, it falls back to using the empty tree hash as the base SHA, which causes Nx to analyze the entire repository history. This can be very slow and produces many warnings about packages that no longer exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions