Skip to content

Commit 8c3f5f5

Browse files
glasserAndarist
andauthored
Skip creating a PR when all existing changesets are empty (#206)
* 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 <[email protected]>
1 parent 6a46d2c commit 8c3f5f5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/action": patch
3+
---
4+
5+
Skip creating a PR when all existing changesets are empty.

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
3737

3838
let publishScript = core.getInput("publish");
3939
let hasChangesets = changesets.length !== 0;
40+
const hasNonEmptyChangesets = changesets.some(
41+
(changeset) => changeset.releases.length > 0
42+
);
4043
let hasPublishScript = !!publishScript;
4144

4245
core.setOutput("published", "false");
@@ -96,6 +99,9 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
9699
}
97100
return;
98101
}
102+
case hasChangesets && !hasNonEmptyChangesets:
103+
console.log("All changesets are empty; not creating PR");
104+
return;
99105
case hasChangesets:
100106
const { pullRequestNumber } = await runVersion({
101107
script: getOptionalInput("version"),

0 commit comments

Comments
 (0)