Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
maxprilutskiy committed Oct 7, 2024
1 parent 9e6d597 commit 14f1537
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,38 @@ import doStuff from './do-stuff.js';
const config = await loadConfig();
const octokit = await loadOctokit();

// Do stuff
await doStuff();
// Commit changes
execSync('git config --global user.name "Replexica"');
execSync('git config --global user.email "support@replexica.com"');
execSync(`git config --global safe.directory ${process.cwd()}`);

if (!config.isPullRequestMode) {
// Do stuff
await doStuff();
execSync('git add .');
execSync(`git commit -m "${config.commitMessage}"`);
execSync('git push');
} else {
// Calculate automated branch name
const prBranchName = `replexica/${config.currentBranchName}`;

// Create branch
execSync(`git checkout -b ${prBranchName}`);
const branchExists = await octokit.rest.repos.getBranch({
owner: config.repositoryOwner,
repo: config.repositoryName,
branch: prBranchName,
}).then(({ status }) => status === 200);

if (branchExists) {
execSync(`git checkout ${prBranchName}`);
execSync('git pull');
// merge current branch into pr branch
execSync(`git merge ${config.currentBranchName}`);
} else {
// Create branch
execSync(`git checkout -b ${prBranchName}`);
}

// Do stuff
await doStuff();
execSync('git add .');
execSync(`git commit -m "${config.commitMessage}"`);
execSync(`git push --set-upstream origin "${prBranchName}"`);
Expand Down

0 comments on commit 14f1537

Please sign in to comment.