Compare commits

...

1 Commits

Author SHA1 Message Date
aksm-ms
673e01b856 adding main.ts 2020-11-03 12:36:29 +05:30
2 changed files with 28 additions and 8 deletions

View File

@@ -36,7 +36,16 @@ function main() {
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
azPath = yield io.which("az", true);
yield executeAzCliCommand("--version");
let output = "";
const options = {
listeners: {
stdout: (data) => {
output += data.toString();
}
}
};
yield executeAzCliCommand("--version", true, options);
core.debug(`az cli version used:\n${output}`);
let creds = core.getInput('creds', { required: true });
let secrets = new actions_secret_parser_1.SecretParser(creds, actions_secret_parser_1.FormatType.JSON);
let servicePrincipalId = secrets.getSecret("$.clientId", false);
@@ -76,10 +85,11 @@ function main() {
}
});
}
function executeAzCliCommand(command, silent) {
function executeAzCliCommand(command, silent, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
options.silent = !!silent;
try {
yield exec.exec(`"${azPath}" ${command}`, [], { silent: !!silent });
yield exec.exec(`"${azPath}" ${command}`, [], options);
}
catch (error) {
throw new Error(error);

View File

@@ -21,8 +21,17 @@ async function main() {
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
azPath = await io.which("az", true);
await executeAzCliCommand("--version");
let output: string = "";
const options: any = {
listeners: {
stdout: (data: Buffer) => {
output += data.toString();
}
}
};
await executeAzCliCommand("--version", true, options);
core.debug(`az cli version used:\n${output}`);
let creds = core.getInput('creds', { required: true });
let secrets = new SecretParser(creds, FormatType.JSON);
let servicePrincipalId = secrets.getSecret("$.clientId", false);
@@ -59,13 +68,14 @@ async function main() {
}
}
async function executeAzCliCommand(command: string, silent?: boolean) {
async function executeAzCliCommand(command: string, silent?: boolean, options: any = {}) {
options.silent = !!silent;
try {
await exec.exec(`"${azPath}" ${command}`, [], {silent: !!silent});
await exec.exec(`"${azPath}" ${command}`, [], options);
}
catch(error) {
throw new Error(error);
}
}
main();
main();