From 1ed9bc24b7a56462c183eb815c8f4bdf0e2e5785 Mon Sep 17 00:00:00 2001 From: David Register Date: Sun, 23 Jan 2022 08:25:45 -0500 Subject: [PATCH] Added `cwd` input option (#134) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add cwd for projects that not in the root directory * docs: add cwd to README * reword the added log * tweak changeset Co-authored-by: Mateusz BurzyƄski --- .changeset/kind-apes-exist.md | 5 +++++ README.md | 1 + action.yml | 3 +++ src/index.ts | 8 +++++++- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .changeset/kind-apes-exist.md diff --git a/.changeset/kind-apes-exist.md b/.changeset/kind-apes-exist.md new file mode 100644 index 0000000..fef214a --- /dev/null +++ b/.changeset/kind-apes-exist.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": minor +--- + +Added `cwd` input option that can be used in projects that are not in the root directory. diff --git a/README.md b/README.md index a506d6a..5d2441f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a - commit - The commit message to use. Default to `Version Packages` - title - The pull request title. Default to `Version Packages` - setupGitUser - Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` +- cwd - Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()` ### Outputs diff --git a/action.yml b/action.yml index ec14c00..a20bda1 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,9 @@ inputs: version: description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided" required: false + cwd: + description: Sets the cwd for the node process. Default to `process.cwd()` + required: false commit: description: | The commit message. Default to `Version Packages` diff --git a/src/index.ts b/src/index.ts index b19db8f..2428f3b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; return; } - let setupGitUser = core.getBooleanInput('setupGitUser'); + let setupGitUser = core.getBooleanInput("setupGitUser"); if (setupGitUser) { console.log("setting git user"); @@ -27,6 +27,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; `machine github.com\nlogin github-actions[bot]\npassword ${githubToken}` ); + const inputCwd = core.getInput("cwd"); + if (inputCwd) { + console.log("changing directory to the one given as the input"); + process.chdir(inputCwd); + } + let { changesets } = await readChangesetState(); let publishScript = core.getInput("publish");