Add generated auth and setup-java

This commit is contained in:
Bryan Clark 2019-11-20 10:25:37 -08:00
parent 56eacf97f5
commit 86e89385e5
2 changed files with 29 additions and 17 deletions

View file

@ -18,18 +18,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io"));
exports.M2_DIR = '.m2';
exports.SETTINGS_FILE = 'settings.xml';
function configAuthentication(username, password) {
return __awaiter(this, void 0, void 0, function* () {
const directory = path.join(os.homedir(), '.m2');
if (username && password) {
core.debug(`configAuthentication with ${username} and a password`);
const directory = path.join(os.homedir(), exports.M2_DIR);
yield io.mkdirP(directory);
core.debug(`created directory ${directory}`);
yield write(directory, generate(username, password));
}
else {
core.debug(`no auth without username: ${username} and password: ${password}`);
}
});
}
exports.configAuthentication = configAuthentication;
// only exported for testing purposes
function generate(username = '${actions.username}', password = '${actions.password}') {
return `<settings>
function generate(username, password) {
return `
<settings>
<servers>
<server>
<username>${username}</username>
@ -42,6 +53,9 @@ function generate(username = '${actions.username}', password = '${actions.passwo
exports.generate = generate;
function write(directory, settings) {
return __awaiter(this, void 0, void 0, function* () {
return fs.writeFileSync(path.join(directory, 'settings.xml'), settings);
const options = { encoding: 'utf-8' };
const location = path.join(directory, exports.SETTINGS_FILE);
core.debug(`writing ${location}`);
return fs.writeFileSync(location, settings, options);
});
}

View file

@ -31,9 +31,7 @@ function run() {
yield installer.getJava(version, arch, jdkFile);
const username = core.getInput('username', { required: false });
const password = core.getInput('password', { required: false });
if (username && password) {
yield auth.configAuthentication(username, password);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
}