Skip to content

Commit

Permalink
Fixes actions#85. Add support for multiple servers.
Browse files Browse the repository at this point in the history
  • Loading branch information
drewctaylorgtri committed Aug 1, 2020
1 parent 1253a7e commit 2b68012
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export const M2_DIR = '.m2';
export const SETTINGS_FILE = 'settings.xml';

export async function configAuthentication(
id: string,
idArray: string[],
username: string,
password: string,
gpgPassphrase: string | undefined = undefined
) {
console.log(
`creating ${SETTINGS_FILE} with server-id: ${id};`,
`creating ${SETTINGS_FILE} with server-id: ${idArray.join(',')};`,
'environment variables:',
`username=\$${username},`,
`password=\$${password},`,
Expand All @@ -32,13 +32,13 @@ export async function configAuthentication(
core.debug(`created directory ${settingsDirectory}`);
await write(
settingsDirectory,
generate(id, username, password, gpgPassphrase)
generate(idArray, username, password, gpgPassphrase)
);
}

// only exported for testing purposes
export function generate(
id: string,
idArray: string[],
username: string,
password: string,
gpgPassphrase: string | undefined = undefined
Expand All @@ -50,13 +50,13 @@ export function generate(
'@xsi:schemaLocation':
'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd',
servers: {
server: [
{
server: idArray.map((id, index, idArray) => {
return {
id: id,
username: `\${env.${username}}`,
password: `\${env.${password}}`
}
]
})
}
}
};
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const INPUT_ARCHITECTURE = 'architecture';
export const INPUT_JAVA_PACKAGE = 'java-package';
export const INPUT_JDK_FILE = 'jdkFile';
export const INPUT_SERVER_ID = 'server-id';
export const INPUT_SERVER_ID_LIST = 'server-id-list';
export const INPUT_SERVER_USERNAME = 'server-username';
export const INPUT_SERVER_PASSWORD = 'server-password';
export const INPUT_SETTINGS_PATH = 'settings-path';
Expand Down
5 changes: 3 additions & 2 deletions src/setup-java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ async function run() {
const matchersPath = path.join(__dirname, '..', '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);

const id = core.getInput(constants.INPUT_SERVER_ID, {required: false});
const id = core.getInput(constants.INPUT_SERVER_ID, {required: false}) || []
const idList = core.getInput(constants.INPUT_SERVER_ID_LIST, {required: false}).split(',') || []
const username = core.getInput(constants.INPUT_SERVER_USERNAME, {
required: false
});
Expand All @@ -40,7 +41,7 @@ async function run() {
core.setSecret(gpgPrivateKey);
}

await auth.configAuthentication(id, username, password, gpgPassphrase);
await auth.configAuthentication(idList.concat(id), username, password, gpgPassphrase);

if (gpgPrivateKey) {
core.info('importing private key');
Expand Down

0 comments on commit 2b68012

Please sign in to comment.