catch gh auth error
							parent
							
								
									d02831dbe6
								
							
						
					
					
						commit
						3f9853712f
					
				|  | @ -736,7 +736,7 @@ exports.CloudRunnerSystem = void 0; | ||||||
| const child_process_1 = __webpack_require__(63129); | const child_process_1 = __webpack_require__(63129); | ||||||
| const remote_client_logger_1 = __webpack_require__(28082); | const remote_client_logger_1 = __webpack_require__(28082); | ||||||
| class CloudRunnerSystem { | class CloudRunnerSystem { | ||||||
|     static Run(command) { |     static Run(command, suppressError = false) { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|             for (const element of command.split(`\n`)) { |             for (const element of command.split(`\n`)) { | ||||||
|                 remote_client_logger_1.RemoteClientLogger.log(element); |                 remote_client_logger_1.RemoteClientLogger.log(element); | ||||||
|  | @ -744,7 +744,7 @@ class CloudRunnerSystem { | ||||||
|             return yield new Promise((promise) => { |             return yield new Promise((promise) => { | ||||||
|                 let output = ''; |                 let output = ''; | ||||||
|                 const child = child_process_1.exec(command, (error, stdout, stderr) => { |                 const child = child_process_1.exec(command, (error, stdout, stderr) => { | ||||||
|                     if (error) { |                     if (error && !suppressError) { | ||||||
|                         throw error; |                         throw error; | ||||||
|                     } |                     } | ||||||
|                     if (stderr) { |                     if (stderr) { | ||||||
|  | @ -758,7 +758,7 @@ class CloudRunnerSystem { | ||||||
|                 }); |                 }); | ||||||
|                 child.on('close', function (code) { |                 child.on('close', function (code) { | ||||||
|                     remote_client_logger_1.RemoteClientLogger.log(`[Exit code ${code}]`); |                     remote_client_logger_1.RemoteClientLogger.log(`[Exit code ${code}]`); | ||||||
|                     if (code !== 0) { |                     if (code !== 0 && !suppressError) { | ||||||
|                         throw new Error(output); |                         throw new Error(output); | ||||||
|                     } |                     } | ||||||
|                     const outputLines = output.split(`\n`); |                     const outputLines = output.split(`\n`); | ||||||
|  | @ -3728,8 +3728,11 @@ class GithubCliReader { | ||||||
|     static GetGitHubAuthToken() { |     static GetGitHubAuthToken() { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|             try { |             try { | ||||||
|                 // eslint-disable-next-line github/no-then
 |                 const authStatus = yield cloud_runner_system_1.CloudRunnerSystem.Run(`gh auth status`, true); | ||||||
|                 return ((yield cloud_runner_system_1.CloudRunnerSystem.Run(`gh auth status -t`).catch(() => { })) || '') |                 if (authStatus.includes('You are not logged') || authStatus === '') { | ||||||
|  |                     return ''; | ||||||
|  |                 } | ||||||
|  |                 return (yield cloud_runner_system_1.CloudRunnerSystem.Run(`gh auth status -t`)) | ||||||
|                     .split(`Token: `)[1] |                     .split(`Token: `)[1] | ||||||
|                     .replace(/ /g, '') |                     .replace(/ /g, '') | ||||||
|                     .replace(/\n/g, ''); |                     .replace(/\n/g, ''); | ||||||
|  | @ -3927,9 +3930,7 @@ class Input { | ||||||
|     } |     } | ||||||
|     static githubToken() { |     static githubToken() { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|             return (Input.getInput('githubToken') || |             return Input.getInput('githubToken') || (yield github_cli_1.GithubCliReader.GetGitHubAuthToken()) || ''; | ||||||
|                 (Input.cloudRunnerCluster !== '' ? yield github_cli_1.GithubCliReader.GetGitHubAuthToken() : '') || |  | ||||||
|                 ''); |  | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|     static gitPrivateToken() { |     static gitPrivateToken() { | ||||||
|  |  | ||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -2,14 +2,14 @@ import { exec } from 'child_process'; | ||||||
| import { RemoteClientLogger } from './remote-client-logger'; | import { RemoteClientLogger } from './remote-client-logger'; | ||||||
| 
 | 
 | ||||||
| export class CloudRunnerSystem { | export class CloudRunnerSystem { | ||||||
|   public static async Run(command: string) { |   public static async Run(command: string, suppressError = false) { | ||||||
|     for (const element of command.split(`\n`)) { |     for (const element of command.split(`\n`)) { | ||||||
|       RemoteClientLogger.log(element); |       RemoteClientLogger.log(element); | ||||||
|     } |     } | ||||||
|     return await new Promise<string>((promise) => { |     return await new Promise<string>((promise) => { | ||||||
|       let output = ''; |       let output = ''; | ||||||
|       const child = exec(command, (error, stdout, stderr) => { |       const child = exec(command, (error, stdout, stderr) => { | ||||||
|         if (error) { |         if (error && !suppressError) { | ||||||
|           throw error; |           throw error; | ||||||
|         } |         } | ||||||
|         if (stderr) { |         if (stderr) { | ||||||
|  | @ -23,7 +23,7 @@ export class CloudRunnerSystem { | ||||||
|       }); |       }); | ||||||
|       child.on('close', function (code) { |       child.on('close', function (code) { | ||||||
|         RemoteClientLogger.log(`[Exit code ${code}]`); |         RemoteClientLogger.log(`[Exit code ${code}]`); | ||||||
|         if (code !== 0) { |         if (code !== 0 && !suppressError) { | ||||||
|           throw new Error(output); |           throw new Error(output); | ||||||
|         } |         } | ||||||
|         const outputLines = output.split(`\n`); |         const outputLines = output.split(`\n`); | ||||||
|  |  | ||||||
|  | @ -4,8 +4,11 @@ import * as core from '@actions/core'; | ||||||
| export class GithubCliReader { | export class GithubCliReader { | ||||||
|   static async GetGitHubAuthToken() { |   static async GetGitHubAuthToken() { | ||||||
|     try { |     try { | ||||||
|       // eslint-disable-next-line github/no-then
 |       const authStatus = await CloudRunnerSystem.Run(`gh auth status`, true); | ||||||
|       return ((await CloudRunnerSystem.Run(`gh auth status -t`).catch(() => {})) || '') |       if (authStatus.includes('You are not logged') || authStatus === '') { | ||||||
|  |         return ''; | ||||||
|  |       } | ||||||
|  |       return (await CloudRunnerSystem.Run(`gh auth status -t`)) | ||||||
|         .split(`Token: `)[1] |         .split(`Token: `)[1] | ||||||
|         .replace(/ /g, '') |         .replace(/ /g, '') | ||||||
|         .replace(/\n/g, ''); |         .replace(/\n/g, ''); | ||||||
|  |  | ||||||
|  | @ -161,11 +161,7 @@ class Input { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   static async githubToken() { |   static async githubToken() { | ||||||
|     return ( |     return Input.getInput('githubToken') || (await GithubCliReader.GetGitHubAuthToken()) || ''; | ||||||
|       Input.getInput('githubToken') || |  | ||||||
|       (Input.cloudRunnerCluster !== '' ? await GithubCliReader.GetGitHubAuthToken() : '') || |  | ||||||
|       '' |  | ||||||
|     ); |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   static async gitPrivateToken() { |   static async gitPrivateToken() { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue