MCPcopy Create free account
hub / github.com/Azure/powershell / main

Function main

lib/index.js:8640–8677  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8638let azPSVersion;
8639let userAgentPrefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : "";
8640function main() {
8641 return __awaiter(this, void 0, void 0, function* () {
8642 try {
8643 // Set user agent variable
8644 let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
8645 let actionName = 'AzurePowerShellAction';
8646 let userAgentString = (!!userAgentPrefix ? `${userAgentPrefix}+` : '') + `GITHUBACTIONS_${actionName}_${usrAgentRepo}`;
8647 core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
8648 core.exportVariable('AZUREPS_HOST_ENVIRONMENT', userAgentString);
8649 const inlineScript = core.getInput('inlineScript', { required: true });
8650 azPSVersion = core.getInput('azPSVersion', { required: true }).trim().toLowerCase();
8651 const errorActionPreference = core.getInput('errorActionPreference');
8652 const failOnStandardError = core.getInput('failOnStandardError').trim().toLowerCase() === "true";
8653 const githubToken = core.getInput('githubToken');
8654 core.info(`Validating inputs`);
8655 validateInputs(inlineScript, errorActionPreference);
8656 const githubAuth = !githubToken || Utils_1.default.isGhes() ? undefined : `token ${githubToken}`;
8657 const installResult = yield new AzModuleInstaller_1.AzModuleInstaller(azPSVersion, githubAuth).install();
8658 core.info(`Module Az ${azPSVersion} installed from ${installResult.moduleSource}`);
8659 core.info(`Initializing Az Module`);
8660 yield InitializeAzure_1.default.importAzModule(azPSVersion);
8661 core.info(`Initializing Az Module Complete`);
8662 core.info(`Running Az PowerShell Script`);
8663 const scriptRunner = new ScriptRunner_1.default(inlineScript, errorActionPreference, failOnStandardError);
8664 yield scriptRunner.executeFile();
8665 core.info(`Script execution Complete`);
8666 }
8667 catch (error) {
8668 core.setFailed(error);
8669 }
8670 finally {
8671 FileUtils_1.default.deleteFile(ScriptRunner_1.default.filePath);
8672 // Reset AZURE_HTTP_USER_AGENT
8673 core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentPrefix);
8674 core.exportVariable('AZUREPS_HOST_ENVIRONMENT', userAgentPrefix);
8675 }
8676 });
8677}
8678function validateInputs(inlineScript, errorActionPreference) {
8679 if (!inlineScript.trim()) {
8680 throw new Error(`inlineScript is empty. Please enter a valid script.`);

Callers 1

index.jsFile · 0.70

Calls 6

validateInputsFunction · 0.70
isGhesMethod · 0.45
installMethod · 0.45
importAzModuleMethod · 0.45
executeFileMethod · 0.45
deleteFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…