mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-19 00:00:25 +08:00
set github user and password as environment variable
This commit is contained in:
@ -24,7 +24,6 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const process = require('process');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const DOMParser = require('xmldom').DOMParser;
|
const DOMParser = require('xmldom').DOMParser;
|
||||||
@ -103,12 +102,7 @@ function fillServerForGithub(templateXml) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!process.env['GITHUB_ACTOR'] || !process.env['GITHUB_TOKEN'] ) {
|
fillServer(templateXml, 'github', '${env.GITHUB_ACTOR}', '${env.GITHUB_TOKEN}');
|
||||||
core.warning('GITHUB_ACTOR or GITHUB_TOKEN environment variable are not set, github server will not be added');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fillServer(templateXml, 'github', process.env['GITHUB_ACTOR'], process.env['GITHUB_TOKEN']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function activateProfile(template, profileId) {
|
function activateProfile(template, profileId) {
|
||||||
|
|||||||
@ -185,35 +185,15 @@ test('fillServers github', () => {
|
|||||||
const xml = new DOMParser().parseFromString("<servers/>");
|
const xml = new DOMParser().parseFromString("<servers/>");
|
||||||
|
|
||||||
process.env['INPUT_GITHUBSERVER'] = 'true';
|
process.env['INPUT_GITHUBSERVER'] = 'true';
|
||||||
process.env['GITHUB_ACTOR'] = 'githubActor';
|
|
||||||
process.env['GITHUB_TOKEN'] = 'githubToken';
|
|
||||||
|
|
||||||
settings.fillServerForGithub(xml);
|
settings.fillServerForGithub(xml);
|
||||||
|
|
||||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||||
|
|
||||||
expect(xmlStr).toBe('<servers><server><id>github</id><username>githubActor</username><password>githubToken</password></server></servers>');
|
expect(xmlStr).toBe('<servers><server><id>github</id><username>${env.GITHUB_ACTOR}</username><password>${env.GITHUB_TOKEN}</password></server></servers>');
|
||||||
expect(consoleOutput).toEqual([]);
|
expect(consoleOutput).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fillServers github - no GITHUB_* env', () => {
|
|
||||||
|
|
||||||
const xml = new DOMParser().parseFromString("<servers/>");
|
|
||||||
|
|
||||||
process.env['INPUT_GITHUBSERVER'] = 'true';
|
|
||||||
|
|
||||||
settings.fillServerForGithub(xml);
|
|
||||||
|
|
||||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
|
||||||
|
|
||||||
expect(xmlStr).toBe('<servers/>');
|
|
||||||
expect(consoleOutput).toEqual(
|
|
||||||
expect.arrayContaining([
|
|
||||||
expect.stringMatching(/::warning::GITHUB_ACTOR or GITHUB_TOKEN environment variable are not set, github server will not be added/)
|
|
||||||
])
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('addSonatypeSnapshots activate', () => {
|
test('addSonatypeSnapshots activate', () => {
|
||||||
|
|
||||||
process.env['INPUT_SONATYPESNAPSHOTS'] = "true";
|
process.env['INPUT_SONATYPESNAPSHOTS'] = "true";
|
||||||
|
|||||||
Reference in New Issue
Block a user