Skip to content

[v2] Nested Changesets projects cannot be used: working-directory is invalid on uses steps #717

Description

@Poggen

[v2] Nested Changesets projects cannot be used: working-directory is invalid on uses steps

Summary

changesets/action@v2.0.0 removed the cwd input in #659. The associated changeset says to use the step-level working-directory option instead.

However, GitHub Actions only supports working-directory for run steps, not uses steps. This leaves no supported way to run the v2 action when the Changesets project root is a subdirectory of the repository.

The action then uses process.cwd() as its project directory:

https://github.com/changesets/action/blob/v2.0.0/src/index.ts#L13-L16

Minimal repository

.
├── .github/workflows/release.yml
├── packages/example/package.json
└── tools/release
    ├── .changeset/config.json
    ├── .changeset/fuzzy-cats-smile.md
    └── package.json

tools/release/package.json is a private workspace root with @changesets/cli@^3.0.0 and ../../packages/example as a workspace.

The Changesets CLI works from that directory and calculates the expected release:

$ cd tools/release
$ ./node_modules/.bin/changeset status --output status.json
🦋 changeset v3.0.0

# status.json contains example-package 1.0.0 -> 1.0.1

Reproduction A: documented replacement is invalid workflow syntax

- run: npm install --ignore-scripts
  working-directory: tools/release

- uses: changesets/action@v2.0.0
  working-directory: tools/release

Strict workflow validation fails:

$ act --strict --validate --dryrun -W .github/workflows/release.yml
Unknown Property working-directory

GitHub documents jobs.<job_id>.steps[*].working-directory as an option for run steps:

https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsworking-directory

Reproduction B: schema-valid workflow runs the action at repository root

Removing working-directory from the uses step makes the workflow valid:

- run: npm install --ignore-scripts
  working-directory: tools/release

- uses: changesets/action@v2.0.0

Running it produces:

$ act workflow_dispatch --bind --container-architecture linux/amd64 \
    -P ubuntu-latest=catthehacker/ubuntu:act-latest \
    -W .github/workflows/release-root.yml

::error::Error: No package.json could be found upwards from directory <repository-root>

The nested install succeeds before the action is invoked. The error occurs because the action uses the repository root as cwd, where this fixture intentionally has no package.json.

Expected behavior

There should be a supported way to specify a nested Changesets project root, as there was with the v1 cwd input.

Restoring a cwd input (or adding a project-directory input) and resolving it against github.workspace would address this. A regression test should cover a repository whose .changeset, package manager manifest, and Changesets CLI installation are all below the repository root.

Versions

  • changesets/action: v2.0.0
  • @changesets/cli: 3.0.0
  • act: 0.2.89
  • Node: 24.19.0

Related history

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions