Skip to content

Commit 11e1ff4

Browse files
authored
fix: make the changelog code more robust (#22)
1 parent 2167f8a commit 11e1ff4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

actions/trickle-down-changelog/dist/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34409,6 +34409,11 @@ async function run() {
3440934409
const branchesToPRTo = gitBranches.map((branch) => branch.name);
3441034410
// always need to pr to main
3441134411
branchesToPRTo.push('main');
34412+
// make sure we don't pr to the current branch
34413+
const index = branchesToPRTo.indexOf(currentRef);
34414+
if (index > -1) {
34415+
branchesToPRTo.splice(index, 1);
34416+
}
3441234417
const changelog = await promises_namespaceObject.readFile('changelog.txt');
3441334418
let readmeContent = undefined;
3441434419
if (github.context.repo.repo === 'elementor') {
@@ -34433,6 +34438,10 @@ async function createPRWithChangesOnChangelog(sourceBranch, targetBranch, change
3443334438
await promises_namespaceObject.writeFile('changelog.txt', changelogContent);
3443434439
await exec.exec(`git checkout -b ${PRBranchName}`);
3443534440
await exec.exec(`git add changelog.txt readme.txt`);
34441+
// verify that there are changes to commit
34442+
const status = await exec.getExecOutput('git status --porcelain');
34443+
if (!status.stdout)
34444+
return;
3443634445
await exec.exec(`git commit -m "${PRMessage}"`);
3443734446
await exec.exec(`git push --set-upstream origin ${PRBranchName}`);
3443834447
await octokit.request('POST /repos/{owner}/{repo}/pulls', {

actions/trickle-down-changelog/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export async function run() {
6060

6161
// always need to pr to main
6262
branchesToPRTo.push('main');
63+
// make sure we don't pr to the current branch
64+
const index = branchesToPRTo.indexOf(currentRef);
65+
if (index > -1) {
66+
branchesToPRTo.splice(index, 1);
67+
}
6368

6469
const changelog = await fs.readFile('changelog.txt');
6570
let readmeContent = undefined;
@@ -97,6 +102,9 @@ async function createPRWithChangesOnChangelog(
97102
await fs.writeFile('changelog.txt', changelogContent);
98103
await exec.exec(`git checkout -b ${PRBranchName}`);
99104
await exec.exec(`git add changelog.txt readme.txt`);
105+
// verify that there are changes to commit
106+
const status = await exec.getExecOutput('git status --porcelain');
107+
if (!status.stdout) return;
100108
await exec.exec(`git commit -m "${PRMessage}"`);
101109
await exec.exec(`git push --set-upstream origin ${PRBranchName}`);
102110
await octokit.request('POST /repos/{owner}/{repo}/pulls', {

0 commit comments

Comments
 (0)