mirror of
				https://github.com/actions/setup-java.git
				synced 2025-11-04 08:20:54 +00:00 
			
		
		
		
	Added support for GPG
This commit is contained in:
		
					parent
					
						
							
								5c87b70ffe
							
						
					
				
			
			
				commit
				
					
						d94db22179
					
				
			
		
					 17 changed files with 37442 additions and 5142 deletions
				
			
		| 
						 | 
				
			
			@ -1,10 +1,20 @@
 | 
			
		|||
import * as core from '@actions/core';
 | 
			
		||||
import * as installer from './installer';
 | 
			
		||||
import * as auth from './auth';
 | 
			
		||||
import * as gpg from './gpg';
 | 
			
		||||
import * as path from 'path';
 | 
			
		||||
 | 
			
		||||
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';
 | 
			
		||||
 | 
			
		||||
async function run() {
 | 
			
		||||
  try {
 | 
			
		||||
    // Set secrets before use
 | 
			
		||||
    core.setSecret('gpg-private-key');
 | 
			
		||||
 | 
			
		||||
    let version = core.getInput('version');
 | 
			
		||||
    if (!version) {
 | 
			
		||||
      version = core.getInput('java-version', {required: true});
 | 
			
		||||
| 
						 | 
				
			
			@ -15,16 +25,28 @@ async function run() {
 | 
			
		|||
 | 
			
		||||
    await installer.getJava(version, arch, jdkFile, javaPackage);
 | 
			
		||||
 | 
			
		||||
    const matchersPath = path.join(__dirname, '..', '.github');
 | 
			
		||||
    const matchersPath = path.join(__dirname, '..', '..', '.github');
 | 
			
		||||
    console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
 | 
			
		||||
 | 
			
		||||
    const id = core.getInput('server-id', {required: false}) || undefined;
 | 
			
		||||
    const id = core.getInput('server-id', {required: false}) || DEFAULT_ID;
 | 
			
		||||
    const username =
 | 
			
		||||
      core.getInput('server-username', {required: false}) || undefined;
 | 
			
		||||
      core.getInput('server-username', {required: false}) || DEFAULT_USERNAME;
 | 
			
		||||
    const password =
 | 
			
		||||
      core.getInput('server-password', {required: false}) || undefined;
 | 
			
		||||
      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);
 | 
			
		||||
 | 
			
		||||
    await auth.configAuthentication(id, username, password);
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    core.setFailed(error.message);
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue