Skip to content

Commit

Permalink
fix: smarter file staging logic
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Aug 9, 2022
1 parent edafd3b commit 2f5c553
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
18 changes: 11 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions src/jobs/commitChangesToGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,23 @@ export default async function commitChangesToGit(jp: FSJetpack): Promise<void> {

await git.addConfig('user.name', config.author.name).addConfig('user.email', config.author.email);

const status = await git.status();

if (status.isClean()) {
log('No changes to commit.');
return;
}

debugLog(`** Staging all changes`);

if (core.getInput('commit_all_dirty') === 'true') await git.add(['-A']);

// For monorepos
await git.add(["':(glob)**/*/js/dist-typings/*'"]);
await git.add(["':(glob)**/*/js/dist/*'"]);

// For non-monorepos
await git.add(['dist/*']);
await git.add(['dist-typings/*']);
status.files.forEach((file) => {
if (file.path.match(/^([A-z0-9_\/-]*\/){0,1}js\/(?:dist|dist-typings)\/.*$/)) {
debugLog(`** Staging ${file.path}`);
git.add(file.path);
}
});

const hash = process.env.GITHUB_SHA;

Expand All @@ -61,8 +67,6 @@ Includes transpiled JS/TS${core.getInput('build_typings_script') !== '' ? ', and

await git.addRemote('upstream', `https://${process.env.GITHUB_ACTOR}:${token}@github.com/${process.env.GITHUB_REPOSITORY}.git`);

const status = await git.status();

log(`${status}`);

await git.push(`upstream`);
Expand Down

0 comments on commit 2f5c553

Please sign in to comment.