Skip to content

Commit 12ea47c

Browse files
committed
Merge branch 'main' into develop
2 parents c997bd4 + a523341 commit 12ea47c

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/release-prepare.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,19 @@ jobs:
3939
HUSKY: 0
4040
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4141

42+
- name: Detect changes after versioning
43+
id: changes
44+
shell: bash
45+
run: |
46+
if git diff --quiet; then
47+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
48+
else
49+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
50+
git status --porcelain
51+
fi
52+
4253
- name: Commit version & changelog changes into prep branch
54+
if: steps.changes.outputs.has_changes == 'true'
4355
uses: stefanzweifel/git-auto-commit-action@v5
4456
with:
4557
commit_message: "chore: version packages (prepare release)"
@@ -49,6 +61,7 @@ jobs:
4961
create_branch: true
5062

5163
- name: Open or update PR to release branch
64+
if: steps.changes.outputs.has_changes == 'true'
5265
uses: actions/github-script@v7
5366
with:
5467
script: |
@@ -64,7 +77,18 @@ jobs:
6477
const pr = existing.data[0];
6578
await github.rest.pulls.update({ owner, repo, pull_number: pr.number, title, body });
6679
core.info(`Updated PR #${pr.number}: ${pr.html_url}`);
67-
} else {
68-
const pr = await github.rest.pulls.create({ owner, repo, head: headBranch, base, title, body });
69-
core.info(`Created PR #${pr.data.number}: ${pr.data.html_url}`);
80+
return;
81+
}
82+
83+
try {
84+
const cmp = await github.rest.repos.compareCommits({ owner, repo, base, head: headBranch });
85+
if (!cmp.data.ahead_by) {
86+
core.info(`No commits ahead in ${headBranch} vs ${base}. Skipping PR creation.`);
87+
return;
88+
}
89+
} catch (e) {
90+
core.info(`compareCommits failed: ${e.message}`);
7091
}
92+
93+
const pr = await github.rest.pulls.create({ owner, repo, head: headBranch, base, title, body });
94+
core.info(`Created PR #${pr.data.number}: ${pr.data.html_url}`);

0 commit comments

Comments
 (0)