8000 Deploy Production Code for Commit c46739c7bde38a88939bc4a71b5b618bb0f… · CasP0/github-pages-deploy-action@bb535ea · GitHub
[go: up one dir, main page]

Skip to content

Commit bb535ea

Browse files
committed
Deploy Production Code for Commit c46739c 🚀
1 parent c46739c commit bb535ea

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

lib/git.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,30 @@ function init(action) {
2626
try {
2727
(0, core_1.info)(`Deploying using ${action.tokenType}… 🔑`);
2828
(0, core_1.info)('Configuring git…');
29-
// Keep trying to configure Git with various different methods until it works with a maximum of 2 attempts.
30-
const ATTEMPT_LIMIT = 2;
31-
let attempt = 0;
32-
let rejected = false;
33-
do {
34-
attempt++;
35-
if (attempt > ATTEMPT_LIMIT) {
36-
throw new Error();
37-
}
38-
if (attempt > 1) {
39-
yield (0, execute_1.execute)(`git init`, action.workspace, action.silent);
40-
yield (0, execute_1.execute)(`git commit -m "Initial commit" --allow-empty`, action.workspace, action.silent);
41-
}
42-
yield (0, execute_1.execute)(`git config --global --add safe.directory "${action.workspace}"`, action.workspace, action.silent);
43-
yield (0, execute_1.execute)(`git config user.name "${action.name}"`, action.workspace, action.silent);
44-
yield (0, execute_1.execute)(`git config user.email "${action.email}"`, action.workspace, action.silent);
45-
yield (0, execute_1.execute)(`git config core.ignorecase false`, action.workspace, action.silent);
46-
} while (rejected);
29+
function configureGit(throwOnError) {
30+
return __awaiter(this, void 0, void 0, function* () {
31+
try {
32+
yield (0, execute_1.execute)(`git config --global --add safe.directory "${action.workspace}"`, action.workspace, action.silent);
33+
yield (0, execute_1.execute)(`git config user.name "${action.name}"`, action.workspace, action.silent);
34+
yield (0, execute_1.execute)(`git config user.email "${action.email}"`, action.workspace, action.silent);
35+
yield (0, execute_1.execute)(`git config core.ignorecase false`, action.workspace, action.silent);
36+
}
37+
catch (_a) {
38+
if (throwOnError) {
39+
throw new Error();
40+
}
41+
}
42+
});
43+
}
44+
try {
45+
yield configureGit(false);
46+
}
47+
catch (_a) {
48+
// Attempt to re-run if initial configuration failed using git init.
49+
yield (0, execute_1.execute)(`git init`, action.workspace, action.silent);
50+
yield (0, execute_1.execute)(`git commit -m "Initial commit" --allow-empty`, action.workspace, action.silent);
51+
yield configureGit(true);
52+
}
4753
try {
4854
if ((process.env.CI && !action.sshKey) || action.isTest) {
4955
/* Ensures that previously set Git configs do not interfere with the deployment.
@@ -55,7 +61,7 @@ function init(action) {
5561
throw new Error();
5662
}
5763
}
58-
catch (_a) {
64+
catch (_b) {
5965
(0, core_1.info)('Unable to unset previous git config authentication as it may not exist, continuing…');
6066
}
6167
try {
@@ -64,7 +70,7 @@ function init(action) {
6470
throw new Error();
6571
}
6672
}
67-
catch (_b) {
73+
catch (_c) {
6874
(0, core_1.info)('Attempted to remove origin but failed, continuing…');
6975
}
7076
yield (0, execute_1.execute)(`git remote add origin ${action.repositoryPath}`, action.workspace, action.silent);

0 commit comments

Comments
 (0)
0