Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make the changelog code more robust #22

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions actions/trickle-down-changelog/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34409,6 +34409,11 @@ async function run() {
const branchesToPRTo = gitBranches.map((branch) => branch.name);
// always need to pr to main
branchesToPRTo.push('main');
// make sure we don't pr to the current branch
const index = branchesToPRTo.indexOf(currentRef);
if (index > -1) {
branchesToPRTo.splice(index, 1);
}
const changelog = await promises_namespaceObject.readFile('changelog.txt');
let readmeContent = undefined;
if (github.context.repo.repo === 'elementor') {
Expand All @@ -34433,6 +34438,10 @@ async function createPRWithChangesOnChangelog(sourceBranch, targetBranch, change
await promises_namespaceObject.writeFile('changelog.txt', changelogContent);
await exec.exec(`git checkout -b ${PRBranchName}`);
await exec.exec(`git add changelog.txt readme.txt`);
// verify that there are changes to commit
const status = await exec.getExecOutput('git status --porcelain');
if (!status.stdout)
return;
await exec.exec(`git commit -m "${PRMessage}"`);
await exec.exec(`git push --set-upstream origin ${PRBranchName}`);
await octokit.request('POST /repos/{owner}/{repo}/pulls', {
Expand Down
8 changes: 8 additions & 0 deletions actions/trickle-down-changelog/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export async function run() {

// always need to pr to main
branchesToPRTo.push('main');
// make sure we don't pr to the current branch
const index = branchesToPRTo.indexOf(currentRef);
if (index > -1) {
branchesToPRTo.splice(index, 1);
}

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