-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a4ad0d
commit b1c883f
Showing
2 changed files
with
29 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113817,23 +113817,20 @@ const push = async (coverageDirectory) => { | |
} | ||
(0, core_1.endGroup)(); | ||
const changes = stdout.split("\n").filter((line) => line.trim() !== ""); | ||
/// If `stdout` is empty, there are no changes | ||
console.log(changes); | ||
if (stdout != "") { | ||
if (changes.length === 1 && changes[0].includes(coverageDirectory)) { | ||
changes.pop(); | ||
} | ||
if (changes.length > 0) { | ||
try { | ||
(0, core_1.startGroup)("Push changes"); | ||
await (0, exec_1.exec)('git config --global user.name "github-actions"'); | ||
await (0, exec_1.exec)('git config --global user.email "[email protected]"'); | ||
try { | ||
await (0, exec_1.exec)(`git add -A -- ':!/${coverageDirectory}/*'`); | ||
await (0, exec_1.exec)(`git add -A -- :!${coverageDirectory}/`); | ||
await (0, exec_1.exec)(`git add -A -- :!${coverageDirectory}/*`); | ||
} | ||
catch (e) { | ||
try { | ||
await (0, exec_1.exec)(`git add -A -- :!/${coverageDirectory}/*`); | ||
} | ||
catch (e) { | ||
console.error("Unable to add files", e); | ||
} | ||
console.error("Unable to add files", e); | ||
} | ||
(0, child_process_1.execSync)(`git commit -m 'chore(automated): Lint commit and format' `); | ||
await (0, exec_1.exec)("git push -f"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import { endGroup, setFailed, setOutput, startGroup } from "@actions/core"; | |
import { exec } from "@actions/exec"; | ||
import { execSync } from "child_process"; | ||
import { debug } from "@actions/core"; | ||
import { start } from "repl"; | ||
|
||
/** | ||
* Push changes to the branch | ||
|
@@ -17,33 +18,40 @@ export const push = async (coverageDirectory: string) => { | |
console.error("Unable to check if there are changes", e); | ||
} | ||
endGroup(); | ||
|
||
startGroup("Parse changes and remove coverage directory"); | ||
const changes = stdout.split("\n").filter((line) => line.trim() !== ""); | ||
/// If `stdout` is empty, there are no changes | ||
console.log(changes); | ||
if (stdout != "") { | ||
if (changes.length === 1 && changes[0].includes(coverageDirectory)) { | ||
changes.pop(); | ||
} | ||
endGroup(); | ||
|
||
if (changes.length > 0) { | ||
try { | ||
startGroup("Push changes"); | ||
startGroup("Set up git"); | ||
await exec('git config --global user.name "github-actions"'); | ||
await exec('git config --global user.email "[email protected]"'); | ||
endGroup(); | ||
|
||
try { | ||
await exec(`git add -A -- ':!/${coverageDirectory}/*'`); | ||
startGroup("Stage files"); | ||
await exec(`git add -A -- :!${coverageDirectory}/`); | ||
await exec(`git add -A -- :!${coverageDirectory}/*`); | ||
} catch (e) { | ||
try { | ||
await exec(`git add -A -- :!/${coverageDirectory}/*`); | ||
} catch (e) { | ||
console.error("Unable to add files", e); | ||
} | ||
console.error("Unable to add files", e); | ||
} finally { | ||
endGroup(); | ||
} | ||
|
||
startGroup("Commit changes"); | ||
execSync(`git commit -m 'chore(automated): Lint commit and format' `); | ||
endGroup(); | ||
startGroup("Push changes"); | ||
await exec("git push -f"); | ||
|
||
debug("Changes pushed onto branch"); | ||
endGroup(); | ||
} catch (e) { | ||
console.error("Unable to push changes", e); | ||
setFailed("Unable to push changes to branch"); | ||
} finally { | ||
endGroup(); | ||
} | ||
} | ||
}; | ||
|