From 19102415df55cd1f47e15d84c5b49f85d4c4f4cf Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 22 Feb 2020 14:10:17 +0100 Subject: [PATCH] set github user and password as environment variable --- settings.js | 8 +------- settings.test.js | 22 +--------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/settings.js b/settings.js index 3ad9344b..f6d9e0a8 100644 --- a/settings.js +++ b/settings.js @@ -24,7 +24,6 @@ THE SOFTWARE. const core = require('@actions/core'); const os = require('os'); -const process = require('process'); const path = require('path'); const fs = require('fs'); const DOMParser = require('xmldom').DOMParser; @@ -103,12 +102,7 @@ function fillServerForGithub(templateXml) { return; } - if (!process.env['GITHUB_ACTOR'] || !process.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']); + fillServer(templateXml, 'github', '${env.GITHUB_ACTOR}', '${env.GITHUB_TOKEN}'); } function activateProfile(template, profileId) { diff --git a/settings.test.js b/settings.test.js index e1abba89..d9eb8c53 100644 --- a/settings.test.js +++ b/settings.test.js @@ -185,35 +185,15 @@ test('fillServers github', () => { const xml = new DOMParser().parseFromString(""); process.env['INPUT_GITHUBSERVER'] = 'true'; - process.env['GITHUB_ACTOR'] = 'githubActor'; - process.env['GITHUB_TOKEN'] = 'githubToken'; settings.fillServerForGithub(xml); const xmlStr = new XMLSerializer().serializeToString(xml); - expect(xmlStr).toBe('githubgithubActorgithubToken'); + expect(xmlStr).toBe('github${env.GITHUB_ACTOR}${env.GITHUB_TOKEN}'); expect(consoleOutput).toEqual([]); }); -test('fillServers github - no GITHUB_* env', () => { - - const xml = new DOMParser().parseFromString(""); - - process.env['INPUT_GITHUBSERVER'] = 'true'; - - settings.fillServerForGithub(xml); - - const xmlStr = new XMLSerializer().serializeToString(xml); - - expect(xmlStr).toBe(''); - 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', () => { process.env['INPUT_SONATYPESNAPSHOTS'] = "true";