| 
									
										
										
										
											2019-07-10 10:54:25 -04:00
										 |  |  | import * as core from '@actions/core'; | 
					
						
							| 
									
										
										
										
											2019-07-10 23:11:48 -04:00
										 |  |  | import * as installer from './installer'; | 
					
						
							| 
									
										
										
										
											2019-11-15 16:01:13 -08:00
										 |  |  | import * as auth from './auth'; | 
					
						
							| 
									
										
										
										
											2020-05-02 04:33:15 -07:00
										 |  |  | import * as gpg from './gpg'; | 
					
						
							| 
									
										
										
										
											2019-07-11 22:57:54 -04:00
										 |  |  | import * as path from 'path'; | 
					
						
							| 
									
										
										
										
											2019-07-10 10:54:25 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-02 04:33:15 -07:00
										 |  |  | const DEFAULT_ID = 'github'; | 
					
						
							|  |  |  | const DEFAULT_USERNAME = 'GITHUB_ACTOR'; | 
					
						
							|  |  |  | const DEFAULT_PASSWORD = 'GITHUB_TOKEN'; | 
					
						
							|  |  |  | const DEFAULT_GPG_PRIVATE_KEY = undefined; | 
					
						
							|  |  |  | const DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-10 10:54:25 -04:00
										 |  |  | async function run() { | 
					
						
							| 
									
										
										
										
											2019-07-10 23:11:48 -04:00
										 |  |  |   try { | 
					
						
							| 
									
										
										
										
											2019-08-13 16:24:39 -04:00
										 |  |  |     let version = core.getInput('version'); | 
					
						
							|  |  |  |     if (!version) { | 
					
						
							|  |  |  |       version = core.getInput('java-version', {required: true}); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-07-10 23:11:48 -04:00
										 |  |  |     const arch = core.getInput('architecture', {required: true}); | 
					
						
							| 
									
										
										
										
											2019-11-02 21:39:35 -07:00
										 |  |  |     const javaPackage = core.getInput('java-package', {required: true}); | 
					
						
							| 
									
										
										
										
											2019-07-15 11:26:32 -04:00
										 |  |  |     const jdkFile = core.getInput('jdkFile', {required: false}) || ''; | 
					
						
							| 
									
										
										
										
											2019-07-10 23:11:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-02 21:39:35 -07:00
										 |  |  |     await installer.getJava(version, arch, jdkFile, javaPackage); | 
					
						
							| 
									
										
										
										
											2019-07-11 22:57:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-02 04:33:15 -07:00
										 |  |  |     const matchersPath = path.join(__dirname, '..', '..', '.github'); | 
					
						
							| 
									
										
										
										
											2019-11-28 09:52:58 -08:00
										 |  |  |     console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-02 04:33:15 -07:00
										 |  |  |     const id = core.getInput('server-id', {required: false}) || DEFAULT_ID; | 
					
						
							| 
									
										
										
										
											2019-12-19 15:39:48 -08:00
										 |  |  |     const username = | 
					
						
							| 
									
										
										
										
											2020-05-02 04:33:15 -07:00
										 |  |  |       core.getInput('server-username', {required: false}) || DEFAULT_USERNAME; | 
					
						
							| 
									
										
										
										
											2019-12-19 15:39:48 -08:00
										 |  |  |     const password = | 
					
						
							| 
									
										
										
										
											2020-05-02 04:33:15 -07:00
										 |  |  |       core.getInput('server-password', {required: false}) || DEFAULT_PASSWORD; | 
					
						
							|  |  |  |     const gpgPrivateKey = | 
					
						
							|  |  |  |       core.getInput('gpg-private-key', {required: false}) || | 
					
						
							|  |  |  |       DEFAULT_GPG_PRIVATE_KEY; | 
					
						
							|  |  |  |     const gpgPassphrase = | 
					
						
							|  |  |  |       core.getInput('gpg-passphrase', {required: false}) || | 
					
						
							|  |  |  |       (gpgPrivateKey ? DEFAULT_GPG_PASSPHRASE : undefined); | 
					
						
							| 
									
										
										
										
											2019-11-15 16:01:13 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-22 21:30:38 -07:00
										 |  |  |     if (gpgPrivateKey) { | 
					
						
							|  |  |  |       core.setSecret(gpgPrivateKey); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-02 04:33:15 -07:00
										 |  |  |     await auth.configAuthentication(id, username, password, gpgPassphrase); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (gpgPrivateKey) { | 
					
						
							|  |  |  |       console.log('importing private key'); | 
					
						
							|  |  |  |       const keyFingerprint = (await gpg.importKey(gpgPrivateKey)) || ''; | 
					
						
							|  |  |  |       core.saveState('gpg-private-key-fingerprint', keyFingerprint); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-07-10 23:11:48 -04:00
										 |  |  |   } catch (error) { | 
					
						
							|  |  |  |     core.setFailed(error.message); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-07-10 10:54:25 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | run(); |