Skip to content

Commit 2b68012

Browse files
Fixes actions#85. Add support for multiple servers.
1 parent 1253a7e commit 2b68012

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

‎src/auth.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export const M2_DIR = '.m2';
1010
export const SETTINGS_FILE = 'settings.xml';
1111

1212
export async function configAuthentication(
13-
id: string,
13+
idArray: string[],
1414
username: string,
1515
password: string,
1616
gpgPassphrase: string | undefined = undefined
1717
) {
1818
console.log(
19-
`creating ${SETTINGS_FILE} with server-id: ${id};`,
19+
`creating ${SETTINGS_FILE} with server-id: ${idArray.join(',')};`,
2020
'environment variables:',
2121
`username=\$${username},`,
2222
`password=\$${password},`,
@@ -32,13 +32,13 @@ export async function configAuthentication(
3232
core.debug(`created directory ${settingsDirectory}`);
3333
await write(
3434
settingsDirectory,
35-
generate(id, username, password, gpgPassphrase)
35+
generate(idArray, username, password, gpgPassphrase)
3636
);
3737
}
3838

3939
// only exported for testing purposes
4040
export function generate(
41-
id: string,
41+
idArray: string[],
4242
username: string,
4343
password: string,
4444
gpgPassphrase: string | undefined = undefined
@@ -50,13 +50,13 @@ export function generate(
5050
'@xsi:schemaLocation':
5151
'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd',
5252
servers: {
53-
server: [
54-
{
53+
server: idArray.map((id, index, idArray) => {
54+
return {
5555
id: id,
5656
username: `\${env.${username}}`,
5757
password: `\${env.${password}}`
5858
}
59-
]
59+
})
6060
}
6161
}
6262
};

‎src/constants.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const INPUT_ARCHITECTURE = 'architecture';
44
export const INPUT_JAVA_PACKAGE = 'java-package';
55
export const INPUT_JDK_FILE = 'jdkFile';
66
export const INPUT_SERVER_ID = 'server-id';
7+
export const INPUT_SERVER_ID_LIST = 'server-id-list';
78
export const INPUT_SERVER_USERNAME = 'server-username';
89
export const INPUT_SERVER_PASSWORD = 'server-password';
910
export const INPUT_SETTINGS_PATH = 'settings-path';

‎src/setup-java.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ async function run() {
2222
const matchersPath = path.join(__dirname, '..', '..', '.github');
2323
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
2424

25-
const id = core.getInput(constants.INPUT_SERVER_ID, {required: false});
25+
const id = core.getInput(constants.INPUT_SERVER_ID, {required: false}) || []
26+
const idList = core.getInput(constants.INPUT_SERVER_ID_LIST, {required: false}).split(',') || []
2627
const username = core.getInput(constants.INPUT_SERVER_USERNAME, {
2728
required: false
2829
});
@@ -40,7 +41,7 @@ async function run() {
4041
core.setSecret(gpgPrivateKey);
4142
}
4243

43-
await auth.configAuthentication(id, username, password, gpgPassphrase);
44+
await auth.configAuthentication(idList.concat(id), username, password, gpgPassphrase);
4445

4546
if (gpgPrivateKey) {
4647
core.info('importing private key');

0 commit comments

Comments
 (0)