diff --git a/.changeset/old-socks-unite.md b/.changeset/old-socks-unite.md new file mode 100644 index 00000000..6555673f --- /dev/null +++ b/.changeset/old-socks-unite.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": patch +--- + +Change directory to `cwd` before running git user setup. This fixes an issue when the action starts its execution not in a git repository. diff --git a/src/index.ts b/src/index.ts index 2428f3bc..c1ae29b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; return; } + const inputCwd = core.getInput("cwd"); + if (inputCwd) { + console.log("changing directory to the one given as the input"); + process.chdir(inputCwd); + } + let setupGitUser = core.getBooleanInput("setupGitUser"); if (setupGitUser) { @@ -27,12 +33,6 @@ 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");