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

Function main

src/main.ts:14–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12let userAgentPrefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : "";
13
14async function main() {
15 try {
16 // Set user agent variable
17 let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
18 let actionName = 'AzurePowerShellAction';
19 let userAgentString = (!!userAgentPrefix ? `${userAgentPrefix}+` : '') + `GITHUBACTIONS_${actionName}_${usrAgentRepo}`;
20 core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
21 core.exportVariable('AZUREPS_HOST_ENVIRONMENT', userAgentString);
22
23 const inlineScript: string = core.getInput('inlineScript', { required: true });
24 azPSVersion = core.getInput('azPSVersion', { required: true }).trim().toLowerCase();
25 const errorActionPreference: string = core.getInput('errorActionPreference');
26 const failOnStandardError = core.getInput('failOnStandardError').trim().toLowerCase() === "true";
27 const githubToken = core.getInput('githubToken');
28 core.info(`Validating inputs`);
29 validateInputs(inlineScript, errorActionPreference);
30
31 const githubAuth = !githubToken || Utils.isGhes() ? undefined : `token ${githubToken}`;
32 const installResult = await new AzModuleInstaller(azPSVersion, githubAuth).install();
33 core.info(`Module Az ${azPSVersion} installed from ${installResult.moduleSource}`);
34
35 core.info(`Initializing Az Module`);
36 await InitializeAzure.importAzModule(azPSVersion);
37 core.info(`Initializing Az Module Complete`);
38
39 core.info(`Running Az PowerShell Script`);
40 const scriptRunner: ScriptRunner = new ScriptRunner(inlineScript, errorActionPreference, failOnStandardError);
41 await scriptRunner.executeFile();
42 core.info(`Script execution Complete`);
43 } catch(error) {
44 core.setFailed(error);
45 } finally {
46 FileUtils.deleteFile(ScriptRunner.filePath);
47 // Reset AZURE_HTTP_USER_AGENT
48 core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentPrefix);
49 core.exportVariable('AZUREPS_HOST_ENVIRONMENT', userAgentPrefix);
50 }
51}
52
53function validateInputs(inlineScript: string, errorActionPreference: string) {
54 if (!inlineScript.trim()) {

Callers 1

main.tsFile · 0.70

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…