Skip to content

Commit 556304c

Browse files
committed
3
1 parent 8a4ad0d commit 556304c

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

.coverage/lcov.info

Lines changed: 0 additions & 7 deletions
This file was deleted.

dist/index.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113816,36 +113816,41 @@ const push = async (coverageDirectory) => {
113816113816
console.error("Unable to check if there are changes", e);
113817113817
}
113818113818
(0, core_1.endGroup)();
113819+
(0, core_1.startGroup)("Parse changes and remove coverage directory");
113819113820
const changes = stdout.split("\n").filter((line) => line.trim() !== "");
113820-
/// If `stdout` is empty, there are no changes
113821-
console.log(changes);
113822-
if (stdout != "") {
113821+
if (changes.length === 1 && changes[0].includes(coverageDirectory)) {
113822+
changes.pop();
113823+
}
113824+
(0, core_1.endGroup)();
113825+
if (changes.length > 0) {
113823113826
try {
113824-
(0, core_1.startGroup)("Push changes");
113827+
(0, core_1.startGroup)("Set up git");
113825113828
await (0, exec_1.exec)('git config --global user.name "github-actions"');
113826113829
await (0, exec_1.exec)('git config --global user.email "[email protected]"');
113830+
(0, core_1.endGroup)();
113827113831
try {
113828-
await (0, exec_1.exec)(`git add -A -- ':!/${coverageDirectory}/*'`);
113832+
(0, core_1.startGroup)("Stage files");
113833+
await (0, exec_1.exec)(`git add -A -- :!${coverageDirectory}/`);
113834+
await (0, exec_1.exec)(`git add -A -- :!${coverageDirectory}/*`);
113829113835
}
113830113836
catch (e) {
113831-
try {
113832-
await (0, exec_1.exec)(`git add -A -- :!/${coverageDirectory}/*`);
113833-
}
113834-
catch (e) {
113835-
console.error("Unable to add files", e);
113836-
}
113837+
console.error("Unable to add files", e);
113837113838
}
113839+
finally {
113840+
(0, core_1.endGroup)();
113841+
}
113842+
(0, core_1.startGroup)("Commit changes");
113838113843
(0, child_process_1.execSync)(`git commit -m 'chore(automated): Lint commit and format' `);
113844+
(0, core_1.endGroup)();
113845+
(0, core_1.startGroup)("Push changes");
113839113846
await (0, exec_1.exec)("git push -f");
113840113847
(0, core_2.debug)("Changes pushed onto branch");
113848+
(0, core_1.endGroup)();
113841113849
}
113842113850
catch (e) {
113843113851
console.error("Unable to push changes", e);
113844113852
(0, core_1.setFailed)("Unable to push changes to branch");
113845113853
}
113846-
finally {
113847-
(0, core_1.endGroup)();
113848-
}
113849113854
}
113850113855
};
113851113856
exports.push = push;

src/scripts/push.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { endGroup, setFailed, setOutput, startGroup } from "@actions/core";
22
import { exec } from "@actions/exec";
33
import { execSync } from "child_process";
44
import { debug } from "@actions/core";
5+
import { start } from "repl";
56

67
/**
78
* Push changes to the branch
@@ -17,33 +18,40 @@ export const push = async (coverageDirectory: string) => {
1718
console.error("Unable to check if there are changes", e);
1819
}
1920
endGroup();
20-
21+
startGroup("Parse changes and remove coverage directory");
2122
const changes = stdout.split("\n").filter((line) => line.trim() !== "");
22-
/// If `stdout` is empty, there are no changes
23-
console.log(changes);
24-
if (stdout != "") {
23+
if (changes.length === 1 && changes[0].includes(coverageDirectory)) {
24+
changes.pop();
25+
}
26+
endGroup();
27+
28+
if (changes.length > 0) {
2529
try {
26-
startGroup("Push changes");
30+
startGroup("Set up git");
2731
await exec('git config --global user.name "github-actions"');
2832
await exec('git config --global user.email "[email protected]"');
33+
endGroup();
34+
2935
try {
30-
await exec(`git add -A -- ':!/${coverageDirectory}/*'`);
36+
startGroup("Stage files");
37+
await exec(`git add -A -- :!${coverageDirectory}/`);
38+
await exec(`git add -A -- :!${coverageDirectory}/*`);
3139
} catch (e) {
32-
try {
33-
await exec(`git add -A -- :!/${coverageDirectory}/*`);
34-
} catch (e) {
35-
console.error("Unable to add files", e);
36-
}
40+
console.error("Unable to add files", e);
41+
} finally {
42+
endGroup();
3743
}
38-
44+
startGroup("Commit changes");
3945
execSync(`git commit -m 'chore(automated): Lint commit and format' `);
46+
endGroup();
47+
startGroup("Push changes");
4048
await exec("git push -f");
49+
4150
debug("Changes pushed onto branch");
51+
endGroup();
4252
} catch (e) {
4353
console.error("Unable to push changes", e);
4454
setFailed("Unable to push changes to branch");
45-
} finally {
46-
endGroup();
4755
}
4856
}
4957
};

0 commit comments

Comments
 (0)