mirror of
https://gitea.com/actions/setup-java.git
synced 2025-04-07 07:49:39 +00:00
Adding maven auth support
This commit is contained in:
31
src/auth.ts
Normal file
31
src/auth.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
|
||||
export async function configAuthentication(username: string, password: string) {
|
||||
const directory: string = path.join(os.homedir(), '.m2');
|
||||
await io.mkdirP(directory);
|
||||
await write(directory, generate(username, password));
|
||||
}
|
||||
|
||||
// only exported for testing purposes
|
||||
export function generate(
|
||||
username = '${actions.username}',
|
||||
password = '${actions.password}'
|
||||
) {
|
||||
return `<settings>
|
||||
<servers>
|
||||
<server>
|
||||
<username>${username}</username>
|
||||
<password>${password}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
`;
|
||||
}
|
||||
|
||||
async function write(directory: string, settings: string) {
|
||||
return fs.writeFileSync(path.join(directory, 'settings.xml'), settings);
|
||||
}
|
Reference in New Issue
Block a user