@@ -26,24 +26,30 @@ function init(action) {
26
26
try {
27
27
( 0 , core_1 . info ) ( `Deploying using ${ action . tokenType } … 🔑` ) ;
28
28
( 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
+ }
47
53
try {
48
54
if ( ( process . env . CI && ! action . sshKey ) || action . isTest ) {
49
55
/* Ensures that previously set Git configs do not interfere with the deployment.
@@ -55,7 +61,7 @@ function init(action) {
55
61
throw new Error ( ) ;
56
62
}
57
63
}
58
- catch ( _a ) {
64
+ catch ( _b ) {
59
65
( 0 , core_1 . info ) ( 'Unable to unset previous git config authentication as it may not exist, continuing…' ) ;
60
66
}
61
67
try {
@@ -64,7 +70,7 @@ function init(action) {
64
70
throw new Error ( ) ;
65
71
}
66
72
}
67
- catch ( _b ) {
73
+ catch ( _c ) {
68
74
( 0 , core_1 . info ) ( 'Attempted to remove origin but failed, continuing…' ) ;
69
75
}
70
76
yield ( 0 , execute_1 . execute ) ( `git remote add origin ${ action . repositoryPath } ` , action . workspace , action . silent ) ;
0 commit comments