From 841b12551939c88af8f6df767c24c38a5620fd0d Mon Sep 17 00:00:00 2001 From: Deepak Dahiya <59823596+t-dedah@users.noreply.github.com> Date: Wed, 24 Nov 2021 07:47:13 +0000 Subject: [PATCH] Cherry picked additionalArgument from main --- README.md | 5 ++++- action.yml | 3 +++ dist/index.js | 2 +- src/deploy/scope_managementgroup.ts | 5 +++-- src/deploy/scope_resourcegroup.ts | 5 +++-- src/deploy/scope_subscription.ts | 5 +++-- src/main.ts | 7 ++++--- src/utils/utils.ts | 15 ++++++++++----- 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 764e742..47e9c95 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ A GitHub Action to deploy ARM templates. With this action you can automate your This action can be used to deploy Azure Resource Manager templates at different [deployment scopes](https://docs.microsoft.com/bs-latn-ba/Azure/azure-resource-manager/resource-group-template-deploy-rest#deployment-scope) - resource group deployment scope, subscription deployment scope and management group deployment scopes. +By default, the action only parses the output and does not print them out. In order to get the values of ```outputs```use [this](https://github.com/Azure/arm-deploy#another-example-on-how-to-use-this-action-to-get-the-output-of-arm-template). + ## Dependencies * [Azure Login](https://github.com/Azure/login) Login with your Azure credentials @@ -21,9 +23,10 @@ This action can be used to deploy Azure Resource Manager templates at different * `deploymentMode`: `Incremental`(default) (only add resources to resource group) or `Complete` (remove extra resources from resource group) or `Validate` (only validates the template). * `deploymentName`: Specifies the name of the resource group deployment to create. * `failOnStdErr`: Specify whether to fail the action if some data is written to stderr stream of az cli. Valid values are: true, false. Default value set to true. +* `additionalArguments`: Specify any additional arguments for the deployment. ## Outputs -Every template output will be exported as output. +Every template output will either be exported as output if output is a json object else will be consoled out where output is not a json object. ## Usage diff --git a/action.yml b/action.yml index bbb1532..81a4383 100644 --- a/action.yml +++ b/action.yml @@ -32,6 +32,9 @@ inputs: description: "Specify whether to fail the action if some data is written to stderr stream of az cli. Valid values are: true, false" required: false default: true + additionalArguments: + description: "Specify any additional arguments for the deployment." + required: false branding: color: orange icon: package diff --git a/dist/index.js b/dist/index.js index 2c7aaa9..90753fc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var r=n[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(r.exports,r,r.exports,__webpack_require__);i=false}finally{if(i)delete n[t]}r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(464)}return startup()}({32:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var u;Object.defineProperty(t,"__esModule",{value:true});t.getCmdPath=t.tryGetExecutablePath=t.isRooted=t.isDirectory=t.exists=t.IS_WINDOWS=t.unlink=t.symlink=t.stat=t.rmdir=t.rename=t.readlink=t.readdir=t.mkdir=t.lstat=t.copyFile=t.chmod=void 0;const c=o(n(747));const a=o(n(622));u=c.promises,t.chmod=u.chmod,t.copyFile=u.copyFile,t.lstat=u.lstat,t.mkdir=u.mkdir,t.readdir=u.readdir,t.readlink=u.readlink,t.rename=u.rename,t.rmdir=u.rmdir,t.stat=u.stat,t.symlink=u.symlink,t.unlink=u.unlink;t.IS_WINDOWS=process.platform==="win32";function exists(e){return s(this,void 0,void 0,function*(){try{yield t.stat(e)}catch(e){if(e.code==="ENOENT"){return false}throw e}return true})}t.exists=exists;function isDirectory(e,n=false){return s(this,void 0,void 0,function*(){const r=n?yield t.stat(e):yield t.lstat(e);return r.isDirectory()})}t.isDirectory=isDirectory;function isRooted(e){e=normalizeSeparators(e);if(!e){throw new Error('isRooted() parameter "p" cannot be empty')}if(t.IS_WINDOWS){return e.startsWith("\\")||/^[A-Z]:/i.test(e)}return e.startsWith("/")}t.isRooted=isRooted;function tryGetExecutablePath(e,n){return s(this,void 0,void 0,function*(){let r=undefined;try{r=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(r&&r.isFile()){if(t.IS_WINDOWS){const t=a.extname(e).toUpperCase();if(n.some(e=>e.toUpperCase()===t)){return e}}else{if(isUnixExecutable(r)){return e}}}const i=e;for(const o of n){e=i+o;r=undefined;try{r=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(r&&r.isFile()){if(t.IS_WINDOWS){try{const n=a.dirname(e);const r=a.basename(e).toUpperCase();for(const i of yield t.readdir(n)){if(r===i.toUpperCase()){e=a.join(n,i);break}}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else{if(isUnixExecutable(r)){return e}}}}return""})}t.tryGetExecutablePath=tryGetExecutablePath;function normalizeSeparators(e){e=e||"";if(t.IS_WINDOWS){e=e.replace(/\//g,"\\");return e.replace(/\\\\+/g,"\\")}return e.replace(/\/\/+/g,"/")}function isUnixExecutable(e){return(e.mode&1)>0||(e.mode&8)>0&&e.gid===process.getgid()||(e.mode&64)>0&&e.uid===process.getuid()}function getCmdPath(){var e;return(e=process.env["COMSPEC"])!==null&&e!==void 0?e:`cmd.exe`}t.getCmdPath=getCmdPath},51:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.findInPath=t.which=t.mkdirP=t.rmRF=t.mv=t.cp=void 0;const u=n(357);const c=o(n(129));const a=o(n(622));const l=n(669);const f=o(n(32));const d=l.promisify(c.exec);const p=l.promisify(c.execFile);function cp(e,t,n={}){return s(this,void 0,void 0,function*(){const{force:r,recursive:i,copySourceDirectory:o}=readCopyOptions(n);const s=(yield f.exists(t))?yield f.stat(t):null;if(s&&s.isFile()&&!r){return}const u=s&&s.isDirectory()&&o?a.join(t,a.basename(e)):t;if(!(yield f.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield f.stat(e);if(c.isDirectory()){if(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,u,0,r)}}else{if(a.relative(e,u)===""){throw new Error(`'${u}' and '${e}' are the same file`)}yield copyFile(e,u,r)}})}t.cp=cp;function mv(e,t,n={}){return s(this,void 0,void 0,function*(){if(yield f.exists(t)){let r=true;if(yield f.isDirectory(t)){t=a.join(t,a.basename(e));r=yield f.exists(t)}if(r){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(a.dirname(t));yield f.rename(e,t)})}t.mv=mv;function rmRF(e){return s(this,void 0,void 0,function*(){if(f.IS_WINDOWS){if(/[*"<>|]/.test(e)){throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows')}try{const t=f.getCmdPath();if(yield f.isDirectory(e,true)){yield d(`${t} /s /c "rd /s /q "%inputPath%""`,{env:{inputPath:e}})}else{yield d(`${t} /s /c "del /f /a "%inputPath%""`,{env:{inputPath:e}})}}catch(e){if(e.code!=="ENOENT")throw e}try{yield f.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield f.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield p(`rm`,[`-rf`,`${e}`])}else{yield f.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return s(this,void 0,void 0,function*(){u.ok(e,"a path argument must be provided");yield f.mkdir(e,{recursive:true})})}t.mkdirP=mkdirP;function which(e,t){return s(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(f.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}return t}const n=yield findInPath(e);if(n&&n.length>0){return n[0]}return""})}t.which=which;function findInPath(e){return s(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}const t=[];if(f.IS_WINDOWS&&process.env["PATHEXT"]){for(const e of process.env["PATHEXT"].split(a.delimiter)){if(e){t.push(e)}}}if(f.isRooted(e)){const n=yield f.tryGetExecutablePath(e,t);if(n){return[n]}return[]}if(e.includes(a.sep)){return[]}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(a.delimiter)){if(e){n.push(e)}}}const r=[];for(const i of n){const n=yield f.tryGetExecutablePath(a.join(i,e),t);if(n){r.push(n)}}return r})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const r=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:r}}function cpDirRecursive(e,t,n,r){return s(this,void 0,void 0,function*(){if(n>=255)return;n++;yield mkdirP(t);const i=yield f.readdir(e);for(const o of i){const i=`${e}/${o}`;const s=`${t}/${o}`;const u=yield f.lstat(i);if(u.isDirectory()){yield cpDirRecursive(i,s,n,r)}else{yield copyFile(i,s,r)}}yield f.chmod(t,(yield f.stat(e)).mode)})}function copyFile(e,t,n){return s(this,void 0,void 0,function*(){if((yield f.lstat(e)).isSymbolicLink()){try{yield f.lstat(t);yield f.unlink(t)}catch(e){if(e.code==="EPERM"){yield f.chmod(t,"0666");yield f.unlink(t)}}const n=yield f.readlink(e);yield f.symlink(n,t,f.IS_WINDOWS?"junction":null)}else if(!(yield f.exists(t))||n){yield f.copyFile(e,t)}})}},87:function(e){e.exports=require("os")},93:function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=r(n(827));function ParseOutputs(e){var t=JSON.parse(e);var n=t.properties.outputs;for(const e in n){if(n.hasOwnProperty(e)){i.setOutput(e,n[e].value)}}return n}t.ParseOutputs=ParseOutputs},120:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.getExecOutput=t.exec=void 0;const u=n(304);const c=o(n(860));function exec(e,t,n){return s(this,void 0,void 0,function*(){const r=c.argStringToArray(e);if(r.length===0){throw new Error(`Parameter 'commandLine' cannot be null or empty.`)}const i=r[0];t=r.slice(1).concat(t||[]);const o=new c.ToolRunner(i,t,n);return o.exec()})}t.exec=exec;function getExecOutput(e,t,n){var r,i;return s(this,void 0,void 0,function*(){let o="";let s="";const c=new u.StringDecoder("utf8");const a=new u.StringDecoder("utf8");const l=(r=n===null||n===void 0?void 0:n.listeners)===null||r===void 0?void 0:r.stdout;const f=(i=n===null||n===void 0?void 0:n.listeners)===null||i===void 0?void 0:i.stderr;const d=e=>{s+=a.write(e);if(f){f(e)}};const p=e=>{o+=c.write(e);if(l){l(e)}};const h=Object.assign(Object.assign({},n===null||n===void 0?void 0:n.listeners),{stdout:p,stderr:d});const m=yield exec(e,t,Object.assign(Object.assign({},n),{listeners:h}));o+=c.end();s+=a.end();return{exitCode:m,stdout:o,stderr:s}})}t.getExecOutput=getExecOutput},124:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issueCommand=void 0;const s=o(n(747));const u=o(n(87));const c=n(127);function issueCommand(e,t){const n=process.env[`GITHUB_${e}`];if(!n){throw new Error(`Unable to find environment variable for file command ${e}`)}if(!s.existsSync(n)){throw new Error(`Missing file at path: ${n}`)}s.appendFileSync(n,`${c.toCommandValue(t)}${u.EOL}`,{encoding:"utf8"})}t.issueCommand=issueCommand},127:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.toCommandValue=void 0;function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue},129:function(e){e.exports=require("child_process")},191:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=i(n(827));const s=n(120);const u=n(93);function DeployResourceGroupScope(e,t,n,i,c,a,l){return r(this,void 0,void 0,function*(){if(!t){throw Error("ResourceGroup name must be set.")}var r=yield s.exec(`"${e}" group show --resource-group ${t}`,[],{silent:true,ignoreReturnCode:true});if(r!=0){throw Error(`Resource Group ${t} could not be found.`)}const f=[t?`--resource-group ${t}`:undefined,n?n.startsWith("http")?`--template-uri ${n}`:`--template-file ${n}`:undefined,i&&i!="validate"?`--mode ${i}`:"--mode Incremental",c?`--name "${c}"`:undefined,a?`--parameters ${a}`:undefined].filter(Boolean).join(" ");let d="";let p=false;const h={silent:true,ignoreReturnCode:true,failOnStdErr:false,listeners:{stderr:e=>{let t=e.toString();if(t&&t.trim().length!==0){p=true;o.error(t)}},stdout:e=>{d+=e.toString()},debug:e=>{o.debug(e)}}};const m={silent:true,ignoreReturnCode:true,listeners:{stderr:e=>{o.warning(e.toString())}}};o.info("Validating template...");var g=yield s.exec(`"${e}" deployment group validate ${f} -o json`,[],m);if(i==="validate"&&g!=0){throw new Error("Template validation failed.")}else if(g!=0){o.warning("Template validation failed.")}if(i!="validate"){o.info("Creating deployment...");var y=yield s.exec(`"${e}" deployment group create ${f} -o json`,[],h);if(y!=0){throw new Error("Deployment failed.")}if(p&&l){throw new Error("Deployment process failed as some lines were written to stderr")}o.debug(d);o.info("Parsing outputs...");return u.ParseOutputs(d)}return{}})}t.DeployResourceGroupScope=DeployResourceGroupScope},213:function(e){e.exports=require("timers")},215:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issue=t.issueCommand=void 0;const s=o(n(87));const u=n(127);function issueCommand(e,t,n){const r=new Command(e,t,n);process.stdout.write(r.toString()+s.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const c="::";class Command{constructor(e,t,n){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=n}toString(){let e=c+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const n in this.properties){if(this.properties.hasOwnProperty(n)){const r=this.properties[n];if(r){if(t){t=false}else{e+=","}e+=`${n}=${escapeProperty(r)}`}}}}e+=`${c}${escapeData(this.message)}`;return e}}function escapeData(e){return u.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return u.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},304:function(e){e.exports=require("string_decoder")},357:function(e){e.exports=require("assert")},464:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(827);const i=n(982);i.main().then(()=>{process.exit(0)}).catch(e=>{r.setFailed(e.message);process.exit(1)})},614:function(e){e.exports=require("events")},622:function(e){e.exports=require("path")},669:function(e){e.exports=require("util")},718:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(120);const s=n(93);const u=i(n(827));function DeploySubscriptionScope(e,t,n,i,c,a,l){return r(this,void 0,void 0,function*(){if(!t){throw Error("Region must be set.")}if(i&&i!="validate"){u.warning("This deployment mode is not supported for subscription scoped deployments, this parameter will be ignored!")}const r=[t?`--location "${t}"`:undefined,n?n.startsWith("http")?`--template-uri ${n}`:`--template-file ${n}`:undefined,c?`--name "${c}"`:undefined,a?`--parameters ${a}`:undefined].filter(Boolean).join(" ");let f="";let d=false;const p={silent:true,ignoreReturnCode:true,failOnStdErr:false,listeners:{stderr:e=>{let t=e.toString();if(t&&t.trim().length!==0){d=true;u.error(t)}},stdout:e=>{f+=e.toString()},debug:e=>{u.debug(e)}}};const h={silent:true,ignoreReturnCode:true,listeners:{stderr:e=>{u.warning(e.toString())}}};u.info("Validating template...");var m=yield o.exec(`"${e}" deployment sub validate ${r} -o json`,[],h);if(i==="validate"&&m!=0){throw new Error("Template validation failed.")}else if(m!=0){u.warning("Template validation failed.")}if(i!="validate"){u.info("Creating deployment...");var g=yield o.exec(`"${e}" deployment sub create ${r} -o json`,[],p);if(g!=0){throw new Error("Deployment failed.")}if(d&&l){throw new Error("Deployment process failed as some lines were written to stderr")}u.debug(f);u.info("Parsing outputs...");return s.ParseOutputs(f)}return{}})}t.DeploySubscriptionScope=DeploySubscriptionScope},723:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(120);const s=n(93);const u=i(n(827));function DeployManagementGroupScope(e,t,n,i,c,a,l,f){return r(this,void 0,void 0,function*(){if(!t){throw Error("Region must be set.")}if(i&&i!="validate"){u.warning("This deployment mode is not supported for management group scoped deployments, this parameter will be ignored!")}const r=[t?`--location "${t}"`:undefined,n?n.startsWith("http")?`--template-uri ${n}`:`--template-file ${n}`:undefined,l?`--management-group-id "${l}"`:undefined,c?`--name "${c}"`:undefined,a?`--parameters ${a}`:undefined].filter(Boolean).join(" ");let d="";let p=false;const h={silent:true,ignoreReturnCode:true,failOnStdErr:false,listeners:{stderr:e=>{let t=e.toString();if(t&&t.trim().length!==0){p=true;u.error(t)}},stdout:e=>{d+=e.toString()},debug:e=>{u.debug(e)}}};const m={silent:true,ignoreReturnCode:true,listeners:{stderr:e=>{u.warning(e.toString())}}};u.info("Validating template...");var g=yield o.exec(`"${e}" deployment mg validate ${r} -o json`,[],m);if(i==="validate"&&g!=0){throw new Error("Template validation failed.")}else if(g!=0){u.warning("Template validation failed.")}if(i!="validate"){u.info("Creating deployment...");var y=yield o.exec(`"${e}" deployment mg create ${r} -o json`,[],h);if(y!=0){throw new Error("Deployment failed.")}if(p&&f){throw new Error("Deployment process failed as some lines were written to stderr")}u.debug(d);u.info("Parsing outputs...");return s.ParseOutputs(d)}return{}})}t.DeployManagementGroupScope=DeployManagementGroupScope},747:function(e){e.exports=require("fs")},827:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.getState=t.saveState=t.group=t.endGroup=t.startGroup=t.info=t.warning=t.error=t.debug=t.isDebug=t.setFailed=t.setCommandEcho=t.setOutput=t.getBooleanInput=t.getMultilineInput=t.getInput=t.addPath=t.setSecret=t.exportVariable=t.ExitCode=void 0;const u=n(215);const c=n(124);const a=n(127);const l=o(n(87));const f=o(n(622));var d;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(d=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const n=a.toCommandValue(t);process.env[e]=n;const r=process.env["GITHUB_ENV"]||"";if(r){const t="_GitHubActionsFileCommandDelimeter_";const r=`${e}<<${t}${l.EOL}${n}${l.EOL}${t}`;c.issueCommand("ENV",r)}else{u.issueCommand("set-env",{name:e},n)}}t.exportVariable=exportVariable;function setSecret(e){u.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){c.issueCommand("PATH",e)}else{u.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${f.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const n=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!n){throw new Error(`Input required and not supplied: ${e}`)}if(t&&t.trimWhitespace===false){return n}return n.trim()}t.getInput=getInput;function getMultilineInput(e,t){const n=getInput(e,t).split("\n").filter(e=>e!=="");return n}t.getMultilineInput=getMultilineInput;function getBooleanInput(e,t){const n=["true","True","TRUE"];const r=["false","False","FALSE"];const i=getInput(e,t);if(n.includes(i))return true;if(r.includes(i))return false;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${e}\n`+`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}t.getBooleanInput=getBooleanInput;function setOutput(e,t){process.stdout.write(l.EOL);u.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){u.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=d.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){u.issueCommand("debug",{},e)}t.debug=debug;function error(e){u.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){u.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+l.EOL)}t.info=info;function startGroup(e){u.issue("group",e)}t.startGroup=startGroup;function endGroup(){u.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return s(this,void 0,void 0,function*(){startGroup(e);let n;try{n=yield t()}finally{endGroup()}return n})}t.group=group;function saveState(e,t){u.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},860:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.argStringToArray=t.ToolRunner=void 0;const u=o(n(87));const c=o(n(614));const a=o(n(129));const l=o(n(622));const f=o(n(51));const d=o(n(32));const p=n(213);const h=process.platform==="win32";class ToolRunner extends c.EventEmitter{constructor(e,t,n){super();if(!e){throw new Error("Parameter 'toolPath' cannot be null or empty.")}this.toolPath=e;this.args=t||[];this.options=n||{}}_debug(e){if(this.options.listeners&&this.options.listeners.debug){this.options.listeners.debug(e)}}_getCommandString(e,t){const n=this._getSpawnFileName();const r=this._getSpawnArgs(e);let i=t?"":"[command]";if(h){if(this._isCmdFile()){i+=n;for(const e of r){i+=` ${e}`}}else if(e.windowsVerbatimArguments){i+=`"${n}"`;for(const e of r){i+=` ${e}`}}else{i+=this._windowsQuoteCmdArg(n);for(const e of r){i+=` ${this._windowsQuoteCmdArg(e)}`}}}else{i+=n;for(const e of r){i+=` ${e}`}}return i}_processLineBuffer(e,t,n){try{let r=t+e.toString();let i=r.indexOf(u.EOL);while(i>-1){const e=r.substring(0,i);n(e);r=r.substring(i+u.EOL.length);i=r.indexOf(u.EOL)}return r}catch(e){this._debug(`error processing line. Failed with error ${e}`);return""}}_getSpawnFileName(){if(h){if(this._isCmdFile()){return process.env["COMSPEC"]||"cmd.exe"}}return this.toolPath}_getSpawnArgs(e){if(h){if(this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(const n of this.args){t+=" ";t+=e.windowsVerbatimArguments?n:this._windowsQuoteCmdArg(n)}t+='"';return[t]}}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){const e=this.toolPath.toUpperCase();return this._endsWith(e,".CMD")||this._endsWith(e,".BAT")}_windowsQuoteCmdArg(e){if(!this._isCmdFile()){return this._uvQuoteCmdArg(e)}if(!e){return'""'}const t=[" ","\t","&","(",")","[","]","{","}","^","=",";","!","'","+",",","`","~","|","<",">",'"'];let n=false;for(const r of e){if(t.some(e=>e===r)){n=true;break}}if(!n){return e}let r='"';let i=true;for(let t=e.length;t>0;t--){r+=e[t-1];if(i&&e[t-1]==="\\"){r+="\\"}else if(e[t-1]==='"'){i=true;r+='"'}else{i=false}}r+='"';return r.split("").reverse().join("")}_uvQuoteCmdArg(e){if(!e){return'""'}if(!e.includes(" ")&&!e.includes("\t")&&!e.includes('"')){return e}if(!e.includes('"')&&!e.includes("\\")){return`"${e}"`}let t='"';let n=true;for(let r=e.length;r>0;r--){t+=e[r-1];if(n&&e[r-1]==="\\"){t+="\\"}else if(e[r-1]==='"'){n=true;t+="\\"}else{n=false}}t+='"';return t.split("").reverse().join("")}_cloneExecOptions(e){e=e||{};const t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||false,windowsVerbatimArguments:e.windowsVerbatimArguments||false,failOnStdErr:e.failOnStdErr||false,ignoreReturnCode:e.ignoreReturnCode||false,delay:e.delay||1e4};t.outStream=e.outStream||process.stdout;t.errStream=e.errStream||process.stderr;return t}_getSpawnOptions(e,t){e=e||{};const n={};n.cwd=e.cwd;n.env=e.env;n["windowsVerbatimArguments"]=e.windowsVerbatimArguments||this._isCmdFile();if(e.windowsVerbatimArguments){n.argv0=`"${t}"`}return n}exec(){return s(this,void 0,void 0,function*(){if(!d.isRooted(this.toolPath)&&(this.toolPath.includes("/")||h&&this.toolPath.includes("\\"))){this.toolPath=l.resolve(process.cwd(),this.options.cwd||process.cwd(),this.toolPath)}this.toolPath=yield f.which(this.toolPath,true);return new Promise((e,t)=>s(this,void 0,void 0,function*(){this._debug(`exec tool: ${this.toolPath}`);this._debug("arguments:");for(const e of this.args){this._debug(` ${e}`)}const n=this._cloneExecOptions(this.options);if(!n.silent&&n.outStream){n.outStream.write(this._getCommandString(n)+u.EOL)}const r=new ExecState(n,this.toolPath);r.on("debug",e=>{this._debug(e)});if(this.options.cwd&&!(yield d.exists(this.options.cwd))){return t(new Error(`The cwd: ${this.options.cwd} does not exist!`))}const i=this._getSpawnFileName();const o=a.spawn(i,this._getSpawnArgs(n),this._getSpawnOptions(this.options,i));let s="";if(o.stdout){o.stdout.on("data",e=>{if(this.options.listeners&&this.options.listeners.stdout){this.options.listeners.stdout(e)}if(!n.silent&&n.outStream){n.outStream.write(e)}s=this._processLineBuffer(e,s,e=>{if(this.options.listeners&&this.options.listeners.stdline){this.options.listeners.stdline(e)}})})}let c="";if(o.stderr){o.stderr.on("data",e=>{r.processStderr=true;if(this.options.listeners&&this.options.listeners.stderr){this.options.listeners.stderr(e)}if(!n.silent&&n.errStream&&n.outStream){const t=n.failOnStdErr?n.errStream:n.outStream;t.write(e)}c=this._processLineBuffer(e,c,e=>{if(this.options.listeners&&this.options.listeners.errline){this.options.listeners.errline(e)}})})}o.on("error",e=>{r.processError=e.message;r.processExited=true;r.processClosed=true;r.CheckComplete()});o.on("exit",e=>{r.processExitCode=e;r.processExited=true;this._debug(`Exit code ${e} received from tool '${this.toolPath}'`);r.CheckComplete()});o.on("close",e=>{r.processExitCode=e;r.processExited=true;r.processClosed=true;this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);r.CheckComplete()});r.on("done",(n,r)=>{if(s.length>0){this.emit("stdline",s)}if(c.length>0){this.emit("errline",c)}o.removeAllListeners();if(n){t(n)}else{e(r)}});if(this.options.input){if(!o.stdin){throw new Error("child process missing stdin")}o.stdin.end(this.options.input)}}))})}}t.ToolRunner=ToolRunner;function argStringToArray(e){const t=[];let n=false;let r=false;let i="";function append(e){if(r&&e!=='"'){i+="\\"}i+=e;r=false}for(let o=0;o0){t.push(i);i=""}continue}append(s)}if(i.length>0){t.push(i.trim())}return t}t.argStringToArray=argStringToArray;class ExecState extends c.EventEmitter{constructor(e,t){super();this.processClosed=false;this.processError="";this.processExitCode=0;this.processExited=false;this.processStderr=false;this.delay=1e4;this.done=false;this.timeout=null;if(!t){throw new Error("toolPath must not be empty")}this.options=e;this.toolPath=t;if(e.delay){this.delay=e.delay}}CheckComplete(){if(this.done){return}if(this.processClosed){this._setResult()}else if(this.processExited){this.timeout=p.setTimeout(ExecState.HandleTimeout,this.delay,this)}}_debug(e){this.emit("debug",e)}_setResult(){let e;if(this.processExited){if(this.processError){e=new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`)}else if(this.processExitCode!==0&&!this.options.ignoreReturnCode){e=new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`)}else if(this.processStderr&&this.options.failOnStdErr){e=new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`)}}if(this.timeout){clearTimeout(this.timeout);this.timeout=null}this.done=true;this.emit("done",e,this.processExitCode)}static HandleTimeout(e){if(e.done){return}if(!e.processClosed&&e.processExited){const t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},982:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const i=n(827);const o=n(51);const s=n(191);const u=n(120);const c=n(723);const a=n(718);function main(){return r(this,void 0,void 0,function*(){const e=yield o.which("az",true);const t=i.getInput("scope")||"resourcegroup";const n=i.getInput("subscriptionId");const r=i.getInput("region");const l=i.getInput("resourceGroupName");const f=i.getInput("template");const d=i.getInput("deploymentMode").toLowerCase();const p=i.getInput("deploymentName");const h=i.getInput("parameters");const m=i.getInput("managementGroupId");let g;try{g=i.getBooleanInput("failOnStdErr")}catch(e){g=true}if(t!=="managementgroup"&&n!==""){i.info("Changing subscription context...");yield u.exec(`"${e}" account set --subscription ${n}`,[],{silent:true})}let y={};switch(t){case"resourcegroup":y=yield s.DeployResourceGroupScope(e,l,f,d,p,h,g);break;case"managementgroup":y=yield c.DeployManagementGroupScope(e,r,f,d,p,h,m,g);break;case"subscription":y=yield a.DeploySubscriptionScope(e,r,f,d,p,h,g);break;default:throw new Error("Invalid scope. Valid values are: 'resourcegroup', 'managementgroup', 'subscription'")}return y})}t.main=main}}); \ No newline at end of file +module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var r=n[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(r.exports,r,r.exports,__webpack_require__);i=false}finally{if(i)delete n[t]}r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(464)}return startup()}({32:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var u;Object.defineProperty(t,"__esModule",{value:true});t.getCmdPath=t.tryGetExecutablePath=t.isRooted=t.isDirectory=t.exists=t.IS_WINDOWS=t.unlink=t.symlink=t.stat=t.rmdir=t.rename=t.readlink=t.readdir=t.mkdir=t.lstat=t.copyFile=t.chmod=void 0;const c=o(n(747));const a=o(n(622));u=c.promises,t.chmod=u.chmod,t.copyFile=u.copyFile,t.lstat=u.lstat,t.mkdir=u.mkdir,t.readdir=u.readdir,t.readlink=u.readlink,t.rename=u.rename,t.rmdir=u.rmdir,t.stat=u.stat,t.symlink=u.symlink,t.unlink=u.unlink;t.IS_WINDOWS=process.platform==="win32";function exists(e){return s(this,void 0,void 0,function*(){try{yield t.stat(e)}catch(e){if(e.code==="ENOENT"){return false}throw e}return true})}t.exists=exists;function isDirectory(e,n=false){return s(this,void 0,void 0,function*(){const r=n?yield t.stat(e):yield t.lstat(e);return r.isDirectory()})}t.isDirectory=isDirectory;function isRooted(e){e=normalizeSeparators(e);if(!e){throw new Error('isRooted() parameter "p" cannot be empty')}if(t.IS_WINDOWS){return e.startsWith("\\")||/^[A-Z]:/i.test(e)}return e.startsWith("/")}t.isRooted=isRooted;function tryGetExecutablePath(e,n){return s(this,void 0,void 0,function*(){let r=undefined;try{r=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(r&&r.isFile()){if(t.IS_WINDOWS){const t=a.extname(e).toUpperCase();if(n.some(e=>e.toUpperCase()===t)){return e}}else{if(isUnixExecutable(r)){return e}}}const i=e;for(const o of n){e=i+o;r=undefined;try{r=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(r&&r.isFile()){if(t.IS_WINDOWS){try{const n=a.dirname(e);const r=a.basename(e).toUpperCase();for(const i of yield t.readdir(n)){if(r===i.toUpperCase()){e=a.join(n,i);break}}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else{if(isUnixExecutable(r)){return e}}}}return""})}t.tryGetExecutablePath=tryGetExecutablePath;function normalizeSeparators(e){e=e||"";if(t.IS_WINDOWS){e=e.replace(/\//g,"\\");return e.replace(/\\\\+/g,"\\")}return e.replace(/\/\/+/g,"/")}function isUnixExecutable(e){return(e.mode&1)>0||(e.mode&8)>0&&e.gid===process.getgid()||(e.mode&64)>0&&e.uid===process.getuid()}function getCmdPath(){var e;return(e=process.env["COMSPEC"])!==null&&e!==void 0?e:`cmd.exe`}t.getCmdPath=getCmdPath},51:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.findInPath=t.which=t.mkdirP=t.rmRF=t.mv=t.cp=void 0;const u=n(357);const c=o(n(129));const a=o(n(622));const l=n(669);const f=o(n(32));const d=l.promisify(c.exec);const p=l.promisify(c.execFile);function cp(e,t,n={}){return s(this,void 0,void 0,function*(){const{force:r,recursive:i,copySourceDirectory:o}=readCopyOptions(n);const s=(yield f.exists(t))?yield f.stat(t):null;if(s&&s.isFile()&&!r){return}const u=s&&s.isDirectory()&&o?a.join(t,a.basename(e)):t;if(!(yield f.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield f.stat(e);if(c.isDirectory()){if(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,u,0,r)}}else{if(a.relative(e,u)===""){throw new Error(`'${u}' and '${e}' are the same file`)}yield copyFile(e,u,r)}})}t.cp=cp;function mv(e,t,n={}){return s(this,void 0,void 0,function*(){if(yield f.exists(t)){let r=true;if(yield f.isDirectory(t)){t=a.join(t,a.basename(e));r=yield f.exists(t)}if(r){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(a.dirname(t));yield f.rename(e,t)})}t.mv=mv;function rmRF(e){return s(this,void 0,void 0,function*(){if(f.IS_WINDOWS){if(/[*"<>|]/.test(e)){throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows')}try{const t=f.getCmdPath();if(yield f.isDirectory(e,true)){yield d(`${t} /s /c "rd /s /q "%inputPath%""`,{env:{inputPath:e}})}else{yield d(`${t} /s /c "del /f /a "%inputPath%""`,{env:{inputPath:e}})}}catch(e){if(e.code!=="ENOENT")throw e}try{yield f.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield f.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield p(`rm`,[`-rf`,`${e}`])}else{yield f.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return s(this,void 0,void 0,function*(){u.ok(e,"a path argument must be provided");yield f.mkdir(e,{recursive:true})})}t.mkdirP=mkdirP;function which(e,t){return s(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(f.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}return t}const n=yield findInPath(e);if(n&&n.length>0){return n[0]}return""})}t.which=which;function findInPath(e){return s(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}const t=[];if(f.IS_WINDOWS&&process.env["PATHEXT"]){for(const e of process.env["PATHEXT"].split(a.delimiter)){if(e){t.push(e)}}}if(f.isRooted(e)){const n=yield f.tryGetExecutablePath(e,t);if(n){return[n]}return[]}if(e.includes(a.sep)){return[]}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(a.delimiter)){if(e){n.push(e)}}}const r=[];for(const i of n){const n=yield f.tryGetExecutablePath(a.join(i,e),t);if(n){r.push(n)}}return r})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const r=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:r}}function cpDirRecursive(e,t,n,r){return s(this,void 0,void 0,function*(){if(n>=255)return;n++;yield mkdirP(t);const i=yield f.readdir(e);for(const o of i){const i=`${e}/${o}`;const s=`${t}/${o}`;const u=yield f.lstat(i);if(u.isDirectory()){yield cpDirRecursive(i,s,n,r)}else{yield copyFile(i,s,r)}}yield f.chmod(t,(yield f.stat(e)).mode)})}function copyFile(e,t,n){return s(this,void 0,void 0,function*(){if((yield f.lstat(e)).isSymbolicLink()){try{yield f.lstat(t);yield f.unlink(t)}catch(e){if(e.code==="EPERM"){yield f.chmod(t,"0666");yield f.unlink(t)}}const n=yield f.readlink(e);yield f.symlink(n,t,f.IS_WINDOWS?"junction":null)}else if(!(yield f.exists(t))||n){yield f.copyFile(e,t)}})}},87:function(e){e.exports=require("os")},93:function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=r(n(827));function ParseOutputs(e){var t={};try{var n=JSON.parse(e);t=n.properties.outputs;for(const e in t){if(t.hasOwnProperty(e)){i.setOutput(e,t[e].value)}}}catch(t){console.log(e)}return t}t.ParseOutputs=ParseOutputs},120:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.getExecOutput=t.exec=void 0;const u=n(304);const c=o(n(860));function exec(e,t,n){return s(this,void 0,void 0,function*(){const r=c.argStringToArray(e);if(r.length===0){throw new Error(`Parameter 'commandLine' cannot be null or empty.`)}const i=r[0];t=r.slice(1).concat(t||[]);const o=new c.ToolRunner(i,t,n);return o.exec()})}t.exec=exec;function getExecOutput(e,t,n){var r,i;return s(this,void 0,void 0,function*(){let o="";let s="";const c=new u.StringDecoder("utf8");const a=new u.StringDecoder("utf8");const l=(r=n===null||n===void 0?void 0:n.listeners)===null||r===void 0?void 0:r.stdout;const f=(i=n===null||n===void 0?void 0:n.listeners)===null||i===void 0?void 0:i.stderr;const d=e=>{s+=a.write(e);if(f){f(e)}};const p=e=>{o+=c.write(e);if(l){l(e)}};const h=Object.assign(Object.assign({},n===null||n===void 0?void 0:n.listeners),{stdout:p,stderr:d});const m=yield exec(e,t,Object.assign(Object.assign({},n),{listeners:h}));o+=c.end();s+=a.end();return{exitCode:m,stdout:o,stderr:s}})}t.getExecOutput=getExecOutput},124:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issueCommand=void 0;const s=o(n(747));const u=o(n(87));const c=n(127);function issueCommand(e,t){const n=process.env[`GITHUB_${e}`];if(!n){throw new Error(`Unable to find environment variable for file command ${e}`)}if(!s.existsSync(n)){throw new Error(`Missing file at path: ${n}`)}s.appendFileSync(n,`${c.toCommandValue(t)}${u.EOL}`,{encoding:"utf8"})}t.issueCommand=issueCommand},127:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.toCommandValue=void 0;function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue},129:function(e){e.exports=require("child_process")},191:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=i(n(827));const s=n(120);const u=n(93);function DeployResourceGroupScope(e,t,n,i,c,a,l,f){return r(this,void 0,void 0,function*(){if(!t){throw Error("ResourceGroup name must be set.")}var r=yield s.exec(`"${e}" group show --resource-group ${t}`,[],{silent:true,ignoreReturnCode:true});if(r!=0){throw Error(`Resource Group ${t} could not be found.`)}const d=[t?`--resource-group ${t}`:undefined,n?n.startsWith("http")?`--template-uri ${n}`:`--template-file ${n}`:undefined,i&&i!="validate"?`--mode ${i}`:"--mode Incremental",c?`--name "${c}"`:undefined,a?`--parameters ${a}`:undefined,f?f:undefined].filter(Boolean).join(" ");let p="";let h=false;const m={silent:true,ignoreReturnCode:true,failOnStdErr:false,listeners:{stderr:e=>{let t=e.toString();if(t&&t.trim().length!==0){h=true;o.error(t)}},stdout:e=>{p+=e.toString()},debug:e=>{o.debug(e)}}};const g={silent:true,ignoreReturnCode:true,listeners:{stderr:e=>{o.warning(e.toString())}}};o.info("Validating template...");var y=yield s.exec(`"${e}" deployment group validate ${d} -o json`,[],g);if(i==="validate"&&y!=0){throw new Error("Template validation failed.")}else if(y!=0){o.warning("Template validation failed.")}if(i!="validate"){o.info("Creating deployment...");var v=yield s.exec(`"${e}" deployment group create ${d} -o json`,[],m);if(v!=0){throw new Error("Deployment failed.")}if(h&&l){throw new Error("Deployment process failed as some lines were written to stderr")}o.debug(p);o.info("Parsing outputs...");return u.ParseOutputs(p)}return{}})}t.DeployResourceGroupScope=DeployResourceGroupScope},213:function(e){e.exports=require("timers")},215:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issue=t.issueCommand=void 0;const s=o(n(87));const u=n(127);function issueCommand(e,t,n){const r=new Command(e,t,n);process.stdout.write(r.toString()+s.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const c="::";class Command{constructor(e,t,n){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=n}toString(){let e=c+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const n in this.properties){if(this.properties.hasOwnProperty(n)){const r=this.properties[n];if(r){if(t){t=false}else{e+=","}e+=`${n}=${escapeProperty(r)}`}}}}e+=`${c}${escapeData(this.message)}`;return e}}function escapeData(e){return u.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return u.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},304:function(e){e.exports=require("string_decoder")},357:function(e){e.exports=require("assert")},464:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=n(827);const i=n(982);i.main().then(()=>{process.exit(0)}).catch(e=>{r.setFailed(e.message);process.exit(1)})},614:function(e){e.exports=require("events")},622:function(e){e.exports=require("path")},669:function(e){e.exports=require("util")},718:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(120);const s=n(93);const u=i(n(827));function DeploySubscriptionScope(e,t,n,i,c,a,l,f){return r(this,void 0,void 0,function*(){if(!t){throw Error("Region must be set.")}if(i&&i!="validate"){u.warning("This deployment mode is not supported for subscription scoped deployments, this parameter will be ignored!")}const r=[t?`--location "${t}"`:undefined,n?n.startsWith("http")?`--template-uri ${n}`:`--template-file ${n}`:undefined,c?`--name "${c}"`:undefined,a?`--parameters ${a}`:undefined,f?f:undefined].filter(Boolean).join(" ");let d="";let p=false;const h={silent:true,ignoreReturnCode:true,failOnStdErr:false,listeners:{stderr:e=>{let t=e.toString();if(t&&t.trim().length!==0){p=true;u.error(t)}},stdout:e=>{d+=e.toString()},debug:e=>{u.debug(e)}}};const m={silent:true,ignoreReturnCode:true,listeners:{stderr:e=>{u.warning(e.toString())}}};u.info("Validating template...");var g=yield o.exec(`"${e}" deployment sub validate ${r} -o json`,[],m);if(i==="validate"&&g!=0){throw new Error("Template validation failed.")}else if(g!=0){u.warning("Template validation failed.")}if(i!="validate"){u.info("Creating deployment...");var y=yield o.exec(`"${e}" deployment sub create ${r} -o json`,[],h);if(y!=0){throw new Error("Deployment failed.")}if(p&&l){throw new Error("Deployment process failed as some lines were written to stderr")}u.debug(d);u.info("Parsing outputs...");return s.ParseOutputs(d)}return{}})}t.DeploySubscriptionScope=DeploySubscriptionScope},723:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(120);const s=n(93);const u=i(n(827));function DeployManagementGroupScope(e,t,n,i,c,a,l,f,d){return r(this,void 0,void 0,function*(){if(!t){throw Error("Region must be set.")}if(i&&i!="validate"){u.warning("This deployment mode is not supported for management group scoped deployments, this parameter will be ignored!")}const r=[t?`--location "${t}"`:undefined,n?n.startsWith("http")?`--template-uri ${n}`:`--template-file ${n}`:undefined,l?`--management-group-id "${l}"`:undefined,c?`--name "${c}"`:undefined,a?`--parameters ${a}`:undefined,d?d:undefined].filter(Boolean).join(" ");let p="";let h=false;const m={silent:true,ignoreReturnCode:true,failOnStdErr:false,listeners:{stderr:e=>{let t=e.toString();if(t&&t.trim().length!==0){h=true;u.error(t)}},stdout:e=>{p+=e.toString()},debug:e=>{u.debug(e)}}};const g={silent:true,ignoreReturnCode:true,listeners:{stderr:e=>{u.warning(e.toString())}}};u.info("Validating template...");var y=yield o.exec(`"${e}" deployment mg validate ${r} -o json`,[],g);if(i==="validate"&&y!=0){throw new Error("Template validation failed.")}else if(y!=0){u.warning("Template validation failed.")}if(i!="validate"){u.info("Creating deployment...");var v=yield o.exec(`"${e}" deployment mg create ${r} -o json`,[],m);if(v!=0){throw new Error("Deployment failed.")}if(h&&f){throw new Error("Deployment process failed as some lines were written to stderr")}u.debug(p);u.info("Parsing outputs...");return s.ParseOutputs(p)}return{}})}t.DeployManagementGroupScope=DeployManagementGroupScope},747:function(e){e.exports=require("fs")},827:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.getState=t.saveState=t.group=t.endGroup=t.startGroup=t.info=t.warning=t.error=t.debug=t.isDebug=t.setFailed=t.setCommandEcho=t.setOutput=t.getBooleanInput=t.getMultilineInput=t.getInput=t.addPath=t.setSecret=t.exportVariable=t.ExitCode=void 0;const u=n(215);const c=n(124);const a=n(127);const l=o(n(87));const f=o(n(622));var d;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(d=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const n=a.toCommandValue(t);process.env[e]=n;const r=process.env["GITHUB_ENV"]||"";if(r){const t="_GitHubActionsFileCommandDelimeter_";const r=`${e}<<${t}${l.EOL}${n}${l.EOL}${t}`;c.issueCommand("ENV",r)}else{u.issueCommand("set-env",{name:e},n)}}t.exportVariable=exportVariable;function setSecret(e){u.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){c.issueCommand("PATH",e)}else{u.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${f.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const n=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!n){throw new Error(`Input required and not supplied: ${e}`)}if(t&&t.trimWhitespace===false){return n}return n.trim()}t.getInput=getInput;function getMultilineInput(e,t){const n=getInput(e,t).split("\n").filter(e=>e!=="");return n}t.getMultilineInput=getMultilineInput;function getBooleanInput(e,t){const n=["true","True","TRUE"];const r=["false","False","FALSE"];const i=getInput(e,t);if(n.includes(i))return true;if(r.includes(i))return false;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${e}\n`+`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}t.getBooleanInput=getBooleanInput;function setOutput(e,t){process.stdout.write(l.EOL);u.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){u.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=d.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){u.issueCommand("debug",{},e)}t.debug=debug;function error(e){u.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){u.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+l.EOL)}t.info=info;function startGroup(e){u.issue("group",e)}t.startGroup=startGroup;function endGroup(){u.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return s(this,void 0,void 0,function*(){startGroup(e);let n;try{n=yield t()}finally{endGroup()}return n})}t.group=group;function saveState(e,t){u.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},860:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.argStringToArray=t.ToolRunner=void 0;const u=o(n(87));const c=o(n(614));const a=o(n(129));const l=o(n(622));const f=o(n(51));const d=o(n(32));const p=n(213);const h=process.platform==="win32";class ToolRunner extends c.EventEmitter{constructor(e,t,n){super();if(!e){throw new Error("Parameter 'toolPath' cannot be null or empty.")}this.toolPath=e;this.args=t||[];this.options=n||{}}_debug(e){if(this.options.listeners&&this.options.listeners.debug){this.options.listeners.debug(e)}}_getCommandString(e,t){const n=this._getSpawnFileName();const r=this._getSpawnArgs(e);let i=t?"":"[command]";if(h){if(this._isCmdFile()){i+=n;for(const e of r){i+=` ${e}`}}else if(e.windowsVerbatimArguments){i+=`"${n}"`;for(const e of r){i+=` ${e}`}}else{i+=this._windowsQuoteCmdArg(n);for(const e of r){i+=` ${this._windowsQuoteCmdArg(e)}`}}}else{i+=n;for(const e of r){i+=` ${e}`}}return i}_processLineBuffer(e,t,n){try{let r=t+e.toString();let i=r.indexOf(u.EOL);while(i>-1){const e=r.substring(0,i);n(e);r=r.substring(i+u.EOL.length);i=r.indexOf(u.EOL)}return r}catch(e){this._debug(`error processing line. Failed with error ${e}`);return""}}_getSpawnFileName(){if(h){if(this._isCmdFile()){return process.env["COMSPEC"]||"cmd.exe"}}return this.toolPath}_getSpawnArgs(e){if(h){if(this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(const n of this.args){t+=" ";t+=e.windowsVerbatimArguments?n:this._windowsQuoteCmdArg(n)}t+='"';return[t]}}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){const e=this.toolPath.toUpperCase();return this._endsWith(e,".CMD")||this._endsWith(e,".BAT")}_windowsQuoteCmdArg(e){if(!this._isCmdFile()){return this._uvQuoteCmdArg(e)}if(!e){return'""'}const t=[" ","\t","&","(",")","[","]","{","}","^","=",";","!","'","+",",","`","~","|","<",">",'"'];let n=false;for(const r of e){if(t.some(e=>e===r)){n=true;break}}if(!n){return e}let r='"';let i=true;for(let t=e.length;t>0;t--){r+=e[t-1];if(i&&e[t-1]==="\\"){r+="\\"}else if(e[t-1]==='"'){i=true;r+='"'}else{i=false}}r+='"';return r.split("").reverse().join("")}_uvQuoteCmdArg(e){if(!e){return'""'}if(!e.includes(" ")&&!e.includes("\t")&&!e.includes('"')){return e}if(!e.includes('"')&&!e.includes("\\")){return`"${e}"`}let t='"';let n=true;for(let r=e.length;r>0;r--){t+=e[r-1];if(n&&e[r-1]==="\\"){t+="\\"}else if(e[r-1]==='"'){n=true;t+="\\"}else{n=false}}t+='"';return t.split("").reverse().join("")}_cloneExecOptions(e){e=e||{};const t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||false,windowsVerbatimArguments:e.windowsVerbatimArguments||false,failOnStdErr:e.failOnStdErr||false,ignoreReturnCode:e.ignoreReturnCode||false,delay:e.delay||1e4};t.outStream=e.outStream||process.stdout;t.errStream=e.errStream||process.stderr;return t}_getSpawnOptions(e,t){e=e||{};const n={};n.cwd=e.cwd;n.env=e.env;n["windowsVerbatimArguments"]=e.windowsVerbatimArguments||this._isCmdFile();if(e.windowsVerbatimArguments){n.argv0=`"${t}"`}return n}exec(){return s(this,void 0,void 0,function*(){if(!d.isRooted(this.toolPath)&&(this.toolPath.includes("/")||h&&this.toolPath.includes("\\"))){this.toolPath=l.resolve(process.cwd(),this.options.cwd||process.cwd(),this.toolPath)}this.toolPath=yield f.which(this.toolPath,true);return new Promise((e,t)=>s(this,void 0,void 0,function*(){this._debug(`exec tool: ${this.toolPath}`);this._debug("arguments:");for(const e of this.args){this._debug(` ${e}`)}const n=this._cloneExecOptions(this.options);if(!n.silent&&n.outStream){n.outStream.write(this._getCommandString(n)+u.EOL)}const r=new ExecState(n,this.toolPath);r.on("debug",e=>{this._debug(e)});if(this.options.cwd&&!(yield d.exists(this.options.cwd))){return t(new Error(`The cwd: ${this.options.cwd} does not exist!`))}const i=this._getSpawnFileName();const o=a.spawn(i,this._getSpawnArgs(n),this._getSpawnOptions(this.options,i));let s="";if(o.stdout){o.stdout.on("data",e=>{if(this.options.listeners&&this.options.listeners.stdout){this.options.listeners.stdout(e)}if(!n.silent&&n.outStream){n.outStream.write(e)}s=this._processLineBuffer(e,s,e=>{if(this.options.listeners&&this.options.listeners.stdline){this.options.listeners.stdline(e)}})})}let c="";if(o.stderr){o.stderr.on("data",e=>{r.processStderr=true;if(this.options.listeners&&this.options.listeners.stderr){this.options.listeners.stderr(e)}if(!n.silent&&n.errStream&&n.outStream){const t=n.failOnStdErr?n.errStream:n.outStream;t.write(e)}c=this._processLineBuffer(e,c,e=>{if(this.options.listeners&&this.options.listeners.errline){this.options.listeners.errline(e)}})})}o.on("error",e=>{r.processError=e.message;r.processExited=true;r.processClosed=true;r.CheckComplete()});o.on("exit",e=>{r.processExitCode=e;r.processExited=true;this._debug(`Exit code ${e} received from tool '${this.toolPath}'`);r.CheckComplete()});o.on("close",e=>{r.processExitCode=e;r.processExited=true;r.processClosed=true;this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);r.CheckComplete()});r.on("done",(n,r)=>{if(s.length>0){this.emit("stdline",s)}if(c.length>0){this.emit("errline",c)}o.removeAllListeners();if(n){t(n)}else{e(r)}});if(this.options.input){if(!o.stdin){throw new Error("child process missing stdin")}o.stdin.end(this.options.input)}}))})}}t.ToolRunner=ToolRunner;function argStringToArray(e){const t=[];let n=false;let r=false;let i="";function append(e){if(r&&e!=='"'){i+="\\"}i+=e;r=false}for(let o=0;o0){t.push(i);i=""}continue}append(s)}if(i.length>0){t.push(i.trim())}return t}t.argStringToArray=argStringToArray;class ExecState extends c.EventEmitter{constructor(e,t){super();this.processClosed=false;this.processError="";this.processExitCode=0;this.processExited=false;this.processStderr=false;this.delay=1e4;this.done=false;this.timeout=null;if(!t){throw new Error("toolPath must not be empty")}this.options=e;this.toolPath=t;if(e.delay){this.delay=e.delay}}CheckComplete(){if(this.done){return}if(this.processClosed){this._setResult()}else if(this.processExited){this.timeout=p.setTimeout(ExecState.HandleTimeout,this.delay,this)}}_debug(e){this.emit("debug",e)}_setResult(){let e;if(this.processExited){if(this.processError){e=new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`)}else if(this.processExitCode!==0&&!this.options.ignoreReturnCode){e=new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`)}else if(this.processStderr&&this.options.failOnStdErr){e=new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`)}}if(this.timeout){clearTimeout(this.timeout);this.timeout=null}this.done=true;this.emit("done",e,this.processExitCode)}static HandleTimeout(e){if(e.done){return}if(!e.processClosed&&e.processExited){const t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},982:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const i=n(827);const o=n(51);const s=n(191);const u=n(120);const c=n(723);const a=n(718);function main(){return r(this,void 0,void 0,function*(){const e=yield o.which("az",true);const t=i.getInput("scope")||"resourcegroup";const n=i.getInput("subscriptionId");const r=i.getInput("region");const l=i.getInput("resourceGroupName");const f=i.getInput("template");const d=i.getInput("deploymentMode").toLowerCase();const p=i.getInput("deploymentName");const h=i.getInput("parameters");const m=i.getInput("managementGroupId");const g=i.getInput("additionalArguments");let y;try{y=i.getBooleanInput("failOnStdErr")}catch(e){y=true}if(t!=="managementgroup"&&n!==""){i.info("Changing subscription context...");yield u.exec(`"${e}" account set --subscription ${n}`,[],{silent:true})}let v={};switch(t){case"resourcegroup":v=yield s.DeployResourceGroupScope(e,l,f,d,p,h,y,g);break;case"managementgroup":v=yield c.DeployManagementGroupScope(e,r,f,d,p,h,m,y,g);break;case"subscription":v=yield a.DeploySubscriptionScope(e,r,f,d,p,h,y,g);break;default:throw new Error("Invalid scope. Valid values are: 'resourcegroup', 'managementgroup', 'subscription'")}return v})}t.main=main}}); \ No newline at end of file diff --git a/src/deploy/scope_managementgroup.ts b/src/deploy/scope_managementgroup.ts index 51475c7..7dd43e6 100644 --- a/src/deploy/scope_managementgroup.ts +++ b/src/deploy/scope_managementgroup.ts @@ -3,7 +3,7 @@ import { ExecOptions } from '@actions/exec/lib/interfaces'; import { ParseOutputs, Outputs } from '../utils/utils'; import * as core from '@actions/core'; -export async function DeployManagementGroupScope(azPath: string, region: string, template: string, deploymentMode: string, deploymentName: string, parameters: string, managementGroupId: string, failOnStdErr: Boolean): Promise { +export async function DeployManagementGroupScope(azPath: string, region: string, template: string, deploymentMode: string, deploymentName: string, parameters: string, managementGroupId: string, failOnStdErr: Boolean, additionalArguments: String): Promise { // Check if region is set if (!region) { throw Error("Region must be set.") @@ -21,7 +21,8 @@ export async function DeployManagementGroupScope(azPath: string, region: string, : undefined, managementGroupId ? `--management-group-id "${managementGroupId}"` : undefined, deploymentName ? `--name "${deploymentName}"` : undefined, - parameters ? `--parameters ${parameters}` : undefined + parameters ? `--parameters ${parameters}` : undefined, + additionalArguments ? additionalArguments : undefined ].filter(Boolean).join(' '); // configure exec to write the json output to a buffer diff --git a/src/deploy/scope_resourcegroup.ts b/src/deploy/scope_resourcegroup.ts index d2b7a49..482bd10 100644 --- a/src/deploy/scope_resourcegroup.ts +++ b/src/deploy/scope_resourcegroup.ts @@ -3,7 +3,7 @@ import { exec } from '@actions/exec'; import { ExecOptions } from '@actions/exec/lib/interfaces'; import { ParseOutputs, Outputs } from '../utils/utils'; -export async function DeployResourceGroupScope(azPath: string, resourceGroupName: string, template: string, deploymentMode: string, deploymentName: string, parameters: string, failOnStdErr: Boolean): Promise { +export async function DeployResourceGroupScope(azPath: string, resourceGroupName: string, template: string, deploymentMode: string, deploymentName: string, parameters: string, failOnStdErr: Boolean, additionalArguments: String): Promise { // Check if resourceGroupName is set if (!resourceGroupName) { throw Error("ResourceGroup name must be set.") @@ -23,7 +23,8 @@ export async function DeployResourceGroupScope(azPath: string, resourceGroupName : undefined, deploymentMode && deploymentMode != "validate" ? `--mode ${deploymentMode}` : "--mode Incremental", deploymentName ? `--name "${deploymentName}"` : undefined, - parameters ? `--parameters ${parameters}` : undefined + parameters ? `--parameters ${parameters}` : undefined, + additionalArguments ? additionalArguments : undefined ].filter(Boolean).join(' '); // configure exec to write the json output to a buffer diff --git a/src/deploy/scope_subscription.ts b/src/deploy/scope_subscription.ts index 567fd4b..764fbed 100644 --- a/src/deploy/scope_subscription.ts +++ b/src/deploy/scope_subscription.ts @@ -3,7 +3,7 @@ import { ExecOptions } from '@actions/exec/lib/interfaces'; import { ParseOutputs, Outputs } from '../utils/utils'; import * as core from '@actions/core'; -export async function DeploySubscriptionScope(azPath: string, region: string, template: string, deploymentMode: string, deploymentName: string, parameters: string, failOnStdErr: Boolean): Promise { +export async function DeploySubscriptionScope(azPath: string, region: string, template: string, deploymentMode: string, deploymentName: string, parameters: string, failOnStdErr: Boolean, additionalArguments: String): Promise { // Check if region is set if (!region) { throw Error("Region must be set.") @@ -21,7 +21,8 @@ export async function DeploySubscriptionScope(azPath: string, region: string, te template.startsWith("http") ? `--template-uri ${template}` : `--template-file ${template}` : undefined, deploymentName ? `--name "${deploymentName}"` : undefined, - parameters ? `--parameters ${parameters}` : undefined + parameters ? `--parameters ${parameters}` : undefined, + additionalArguments ? additionalArguments : undefined ].filter(Boolean).join(' '); // configure exec to write the json output to a buffer diff --git a/src/main.ts b/src/main.ts index ea89a34..42076e5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,6 +21,7 @@ export async function main(): Promise { const deploymentName = getInput('deploymentName') const parameters = getInput('parameters') const managementGroupId = getInput('managementGroupId') + const additionalArguments = getInput('additionalArguments') let failOnStdErr try { failOnStdErr = getBooleanInput('failOnStdErr') @@ -39,13 +40,13 @@ export async function main(): Promise { let result: Outputs = {}; switch (scope) { case "resourcegroup": - result = await DeployResourceGroupScope(azPath, resourceGroupName, template, deploymentMode, deploymentName, parameters, failOnStdErr) + result = await DeployResourceGroupScope(azPath, resourceGroupName, template, deploymentMode, deploymentName, parameters, failOnStdErr, additionalArguments) break case "managementgroup": - result = await DeployManagementGroupScope(azPath, region, template, deploymentMode, deploymentName, parameters, managementGroupId, failOnStdErr) + result = await DeployManagementGroupScope(azPath, region, template, deploymentMode, deploymentName, parameters, managementGroupId, failOnStdErr, additionalArguments) break case "subscription": - result = await DeploySubscriptionScope(azPath, region, template, deploymentMode, deploymentName, parameters, failOnStdErr) + result = await DeploySubscriptionScope(azPath, region, template, deploymentMode, deploymentName, parameters, failOnStdErr, additionalArguments) break default: throw new Error("Invalid scope. Valid values are: 'resourcegroup', 'managementgroup', 'subscription'") diff --git a/src/utils/utils.ts b/src/utils/utils.ts index a2ddc89..82889cf 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -3,12 +3,17 @@ import * as core from '@actions/core'; export type Outputs = { [index: string]: { value: string } } export function ParseOutputs(commandOutput: string): Outputs { // parse the result and save the outputs - var result = JSON.parse(commandOutput) as { properties: { outputs: Outputs } } - var object = result.properties.outputs - for (const key in object) { - if (object.hasOwnProperty(key)) { - core.setOutput(key, object[key].value) + var object: Outputs = {} + try { + var result = JSON.parse(commandOutput) as { properties: { outputs: Outputs } } + object = result.properties.outputs + for (const key in object) { + if (object.hasOwnProperty(key)) { + core.setOutput(key, object[key].value) + } } + }catch(err){ + console.log(commandOutput) } return object