diff --git a/.changeset/two-lizards-hope.md b/.changeset/two-lizards-hope.md new file mode 100644 index 00000000..09464aa0 --- /dev/null +++ b/.changeset/two-lizards-hope.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": minor +--- + +Feature: only create the .netrc file if it doesn't already exist. diff --git a/src/index.ts b/src/index.ts index 51ca39e2..2cdf6e92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,11 +27,17 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; await gitUtils.setupUser(); } - core.info("setting GitHub credentials"); - await fs.writeFile( - `${process.env.HOME}/.netrc`, - `machine github.com\nlogin github-actions[bot]\npassword ${githubToken}` - ); + let netrcFilepath = `${process.env.HOME}/.netrc`; + + if (!fs.existsSync(netrcFilepath)) { + core.info("setting GitHub credentials"); + await fs.writeFile( + netrcFilepath, + `machine github.com\nlogin github-actions[bot]\npassword ${githubToken}` + ); + } else { + core.info("GitHub credentials file exists, skipping.Wrap t") + } let { changesets } = await readChangesetState();