Skip to content

Commit

Permalink
Skip creating a PR when all existing changesets are empty (#206)
Browse files Browse the repository at this point in the history
* Don't create a PR if all changesets are empty

Fixes #205.

Note that this maintains the previous behavior that if there are any
changesets (even empty ones), the action does not publish packages.

* Create three-needles-protect.md

* Update .changeset/three-needles-protect.md

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
glasser and Andarist committed Aug 18, 2022
1 parent 6a46d2c commit 8c3f5f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-needles-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/action": patch
---

Skip creating a PR when all existing changesets are empty.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;

let publishScript = core.getInput("publish");
let hasChangesets = changesets.length !== 0;
const hasNonEmptyChangesets = changesets.some(
(changeset) => changeset.releases.length > 0
);
let hasPublishScript = !!publishScript;

core.setOutput("published", "false");
Expand Down Expand Up @@ -96,6 +99,9 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
}
return;
}
case hasChangesets && !hasNonEmptyChangesets:
console.log("All changesets are empty; not creating PR");
return;
case hasChangesets:
const { pullRequestNumber } = await runVersion({
script: getOptionalInput("version"),
Expand Down

0 comments on commit 8c3f5f5

Please sign in to comment.