diff --git a/dist/index.js b/dist/index.js index bc6aa99..fcde0fd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -(()=>{var __webpack_modules__={351:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(87));const s=r(278);function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+o.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const i="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=i+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${i}${escapeData(this.message)}`;return e}}function escapeData(e){return s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},186:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const s=r(351);const i=r(717);const a=r(278);const c=o(r(87));const u=o(r(622));var p;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(p=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const r=a.toCommandValue(t);process.env[e]=r;const n=process.env["GITHUB_ENV"]||"";if(n){const t="_GitHubActionsFileCommandDelimeter_";const n=`${e}<<${t}${c.EOL}${r}${c.EOL}${t}`;i.issueCommand("ENV",n)}else{s.issueCommand("set-env",{name:e},r)}}t.exportVariable=exportVariable;function setSecret(e){s.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){i.issueCommand("PATH",e)}else{s.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${u.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}return r.trim()}t.getInput=getInput;function setOutput(e,t){s.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){s.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=p.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){s.issueCommand("debug",{},e)}t.debug=debug;function error(e){s.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){s.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+c.EOL)}t.info=info;function startGroup(e){s.issue("group",e)}t.startGroup=startGroup;function endGroup(){s.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return n(this,void 0,void 0,(function*(){startGroup(e);let r;try{r=yield t()}finally{endGroup()}return r}))}t.group=group;function saveState(e,t){s.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},717:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(747));const s=n(r(87));const i=r(278);function issueCommand(e,t){const r=process.env[`GITHUB_${e}`];if(!r){throw new Error(`Unable to find environment variable for file command ${e}`)}if(!o.existsSync(r)){throw new Error(`Missing file at path: ${r}`)}o.appendFileSync(r,`${i.toCommandValue(t)}${s.EOL}`,{encoding:"utf8"})}t.issueCommand=issueCommand},278:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});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},67:(e,t,r)=>{const n=r(755);e.exports=(e,t)=>new n(e,t)},755:(e,t,r)=>{const n=r(622);const o=r(605);const s=r(211);const i=r(191);const a=r(761);const{URL:c}=r(835);const u=r(386);const p=["gzip","deflate"];e.exports=class CentraRequest{constructor(e,t="GET"){this.url=typeof e==="string"?new c(e):e;this.method=t;this.data=null;this.sendDataAs=null;this.reqHeaders={};this.streamEnabled=false;this.compressionEnabled=false;this.timeoutTime=null;this.coreOptions={};this.resOptions={maxBuffer:50*1e6};return this}query(e,t){if(typeof e==="object"){Object.keys(e).forEach((t=>{this.url.searchParams.append(t,e[t])}))}else this.url.searchParams.append(e,t);return this}path(e){this.url.pathname=n.join(this.url.pathname,e);return this}body(e,t){this.sendDataAs=typeof e==="object"&&!t&&!Buffer.isBuffer(e)?"json":t?t.toLowerCase():"buffer";this.data=this.sendDataAs==="form"?i.stringify(e):this.sendDataAs==="json"?JSON.stringify(e):e;return this}header(e,t){if(typeof e==="object"){Object.keys(e).forEach((t=>{this.reqHeaders[t.toLowerCase()]=e[t]}))}else this.reqHeaders[e.toLowerCase()]=t;return this}timeout(e){this.timeoutTime=e;return this}option(e,t){this.coreOptions[e]=t;return this}stream(){this.streamEnabled=true;return this}compress(){this.compressionEnabled=true;if(!this.reqHeaders["accept-encoding"])this.reqHeaders["accept-encoding"]=p.join(", ");return this}send(){return new Promise(((e,t)=>{if(this.data){if(!this.reqHeaders.hasOwnProperty("content-type")){if(this.sendDataAs==="json"){this.reqHeaders["content-type"]="application/json"}else if(this.sendDataAs==="form"){this.reqHeaders["content-type"]="application/x-www-form-urlencoded"}}if(!this.reqHeaders.hasOwnProperty("content-length")){this.reqHeaders["content-length"]=Buffer.byteLength(this.data)}}const r=Object.assign({protocol:this.url.protocol,host:this.url.hostname,port:this.url.port,path:this.url.pathname+(this.url.search===null?"":this.url.search),method:this.method,headers:this.reqHeaders},this.coreOptions);let n;const resHandler=r=>{let n=r;if(this.compressionEnabled){if(r.headers["content-encoding"]==="gzip"){n=r.pipe(a.createGunzip())}else if(r.headers["content-encoding"]==="deflate"){n=r.pipe(a.createInflate())}}let o;if(this.streamEnabled){e(n)}else{o=new u(r,this.resOptions);n.on("error",(e=>{t(e)}));n.on("data",(e=>{o._addChunk(e);if(this.resOptions.maxBuffer!==null&&o.body.length>this.resOptions.maxBuffer){n.destroy();t("Received a response which was longer than acceptable when buffering. ("+this.body.length+" bytes)")}}));n.on("end",(()=>{e(o)}))}};if(this.url.protocol==="http:"){n=o.request(r,resHandler)}else if(this.url.protocol==="https:"){n=s.request(r,resHandler)}else throw new Error("Bad URL protocol: "+this.url.protocol);if(this.timeoutTime){n.setTimeout(this.timeoutTime,(()=>{n.abort();if(!this.streamEnabled){t(new Error("Timeout reached"))}}))}n.on("error",(e=>{t(e)}));if(this.data)n.write(this.data);n.end()}))}}},386:e=>{e.exports=class CentraResponse{constructor(e,t){this.coreRes=e;this.resOptions=t;this.body=Buffer.alloc(0);this.headers=e.headers;this.statusCode=e.statusCode}_addChunk(e){this.body=Buffer.concat([this.body,e])}async json(){return this.statusCode===204?null:JSON.parse(this.body)}async text(){return this.body.toString()}}},384:(e,t,r)=>{const{URL:n}=r(835);const o=r(67);const phin=async e=>{if(typeof e!=="string"){if(!e.hasOwnProperty("url")){throw new Error("Missing url option from options for request method.")}}const t=o(typeof e==="object"?e.url:e,e.method||"GET");if(e.headers)t.header(e.headers);if(e.stream)t.stream();if(e.timeout)t.timeout(e.timeout);if(e.data)t.body(e.data);if(e.form)t.body(e.form,"form");if(e.compression)t.compress();if(typeof e.core==="object"){Object.keys(e.core).forEach((r=>{t.option(r,e.core[r])}))}const r=await t.send();if(r.headers.hasOwnProperty("location")&&e.followRedirects){e.url=new n(r.headers["location"],e.url).toString();return await phin(e)}if(e.stream){r.stream=r;return r}else{r.coreRes.body=r.body;if(e.parse&&e.parse==="json"){r.coreRes.body=await r.json();return r.coreRes}else return r.coreRes}};phin.promisified=phin;phin.unpromisified=(e,t)=>{phin(e).then((e=>{if(t)t(null,e)})).catch((e=>{if(t)t(e,null)}))};phin.defaults=e=>async t=>{const r=typeof t==="string"?{url:t}:t;Object.keys(e).forEach((t=>{if(!r.hasOwnProperty(t)||r[t]===null){r[t]=e[t]}}));return await phin(r)};e.exports=phin},153:module=>{module.exports=eval("require")("dotenv")},747:e=>{"use strict";e.exports=require("fs")},605:e=>{"use strict";e.exports=require("http")},211:e=>{"use strict";e.exports=require("https")},87:e=>{"use strict";e.exports=require("os")},622:e=>{"use strict";e.exports=require("path")},191:e=>{"use strict";e.exports=require("querystring")},835:e=>{"use strict";e.exports=require("url")},761:e=>{"use strict";e.exports=require("zlib")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var r=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e].call(r.exports,r,r.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return r.exports}(()=>{__nccwpck_require__.n=e=>{var t=e&&e.__esModule?()=>e["default"]:()=>e;__nccwpck_require__.d(t,{a:t});return t}})();(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__={};(()=>{"use strict";__nccwpck_require__.r(__webpack_exports__);var e=__nccwpck_require__(186);var t=__nccwpck_require__.n(e);const r={green:"",cyan:"",magenta:"",blue:"",red:""};const formatAppdir=e=>e[0]==="."&&e[1]==="/"?e.slice(2):e[0]==="/"?e.slice(1):e;const formatDockerBuildArgs=e=>{const t=e.split("\n").map((e=>`${e}="${process.env[e]}"`)).join(",");return t?"--arg "+t:""};const getHerokuConfig=()=>{t().debug(r.cyan+"STEP: Getting Heroku Config");const e={api_key:t().getInput("heroku_api_key"),email:t().getInput("heroku_email"),app_name:t().getInput("heroku_app_name"),buildpack:t().getInput("buildpack"),branch:t().getInput("branch"),dontuseforce:t().getInput("dontuseforce")==="false"?false:true,dontautocreate:t().getInput("dontautocreate")==="false"?false:true,usedocker:t().getInput("usedocker")==="false"?false:true,dockerHerokuProcessType:t().getInput("docker_heroku_process_type"),dockerBuildArgs:formatDockerBuildArgs(t().getInput("docker_build_args")),appdir:formatAppdir(t().getInput("appdir")),healthcheck:t().getInput("healthcheck"),checkstring:t().getInput("checkstring"),delay:parseInt(t().getInput("delay")),procfile:t().getInput("procfile"),rollbackonhealthcheckfailed:t().getInput("rollbackonhealthcheckfailed")==="false"?false:true,env_file:t().getInput("env_file"),justlogin:t().getInput("justlogin")==="false"?false:true,region:t().getInput("region"),stack:t().getInput("stack"),team:t().getInput("team")};t().info(r.green+"STEP: Getting Heroku Config - Success");return e};const justLogin=e=>!e.justlogin;const n=require("child_process");const createCatFile=({email:e,api_key:t})=>`cat >~/.netrc <{t().debug(r.cyan+"STEP: Login to Heroku");(0,n.execSync)(createCatFile(e));if(e.usedocker){(0,n.execSync)("heroku container:login")}t().info(r.green+"STEP: Login to Heroku - Success");return true};const configureUserAndCommit=e=>{(0,n.execSync)(`git config user.name "Heroku-Deploy"`);(0,n.execSync)(`git config user.email "${e.email}"`);if((0,n.execSync)("git status --porcelain").toString().trim()){(0,n.execSync)('git add -A && git commit -m "Commited changes from previous actions"')}return true};const unshallowRepo=e=>{if(e.usedocker){return true}if((0,n.execSync)("git rev-parse --is-shallow-repository").toString().trim()==="true"){(0,n.execSync)("git fetch --prune --unshallow")}return true};const configureGit=e=>{t().debug(r.cyan+"STEP: Configuring git");configureUserAndCommit(e)&&unshallowRepo(e);t().info(r.green+"STEP: Configuring git - Success");return true};var o=__nccwpck_require__(747);var s=__nccwpck_require__.n(o);var i=__nccwpck_require__(622);var a=__nccwpck_require__.n(i);const createProcfile=e=>{if(e.procfile){t().debug(r.cyan+"STEP: Creating Procfile");s().writeFileSync(a().join(e.appdir,"Procfile"),e.procfile);(0,n.execSync)(`git add -A && git commit -m "Added Procfile"`);t().info(r.green+"STEP: Creating Procfile - Success")}return true};const addRemote=e=>{t().debug(r.cyan+"STEP: Adding Remote");try{(0,n.execSync)("heroku git:remote --app "+e.app_name);t().debug("Added git remote heroku")}catch(t){if(e.dontautocreate){throw t}(0,n.execSync)("heroku create "+e.app_name+(e.buildpack?" --buildpack "+e.buildpack:"")+(e.region?" --region "+e.region:"")+(e.stack?" --stack "+e.stack:"")+(e.team?" --team "+e.team:""))}t().info(r.green+"STEP: Adding Remote - Success");return true};const addVarsFromEnv=e=>{const t=[...e];for(let e in process.env){if(e.startsWith("HD_")){t.push(e.substring(3)+"='"+process.env[e]+"'")}}return t};const addVarsFromEnvFile=(e,t)=>{if(e.env_file){const r=s().readFileSync(a().join(e.appdir,e.env_file),"utf8");const n=__nccwpck_require__(153).parse(r);const o=[];for(let e in n){o.push(e+"="+n[e])}return[...t,...o]}return t};const addConfigVars=e=>{t().debug(r.cyan+"STEP: Adding Configuration Variables from env and envfile");const o=addVarsFromEnv([]);const s=addVarsFromEnvFile(e,o);if(s.length!==0){(0,n.execSync)(`heroku config:set --app=${e.app_name} ${s.join(" ")}`)}t().info(r.green+"STEP: Adding Configuration Variables from env and envfile - Success");return true};const deployDocker=e=>{if(e.usedocker){(0,n.execSync)(`heroku container:push ${e.dockerHerokuProcessType} --app ${e.app_name} ${e.dockerBuildArgs}`,e.appdir?{cwd:e.appdir}:undefined);(0,n.execSync)(`heroku container:release ${e.dockerHerokuProcessType} --app ${e.app_name}`,e.appdir?{cwd:e.appdir}:undefined);return false}return true};const fixRemoteBranch=e=>{let t=(0,n.execSync)("git remote show heroku | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g'").toString().trim();if(t==="master"){(0,n.execSync)("heroku plugins:install heroku-repo");(0,n.execSync)("heroku repo:reset -a "+e.app_name)}return true};const deployGit=(e,o=false)=>{const s=!e.dontuseforce?"--force":"";const i=e.appdir?`\`git subtree split --prefix=${e.appdir} ${e.branch}\``:e.branch;try{(0,n.execSync)(`git push ${s} heroku ${i}:refs/head/main`,{maxBuffer:104857600})}catch(e){if(o){throw e}else{t().error(r.red+("stderr"in e?e.stderr.toString():e.message.toString()));return true}}return false};const deploy=e=>{t().debug(r.cyan+"STEP: Deploying");deployDocker(e)&&fixRemoteBranch(e)&&deployGit(Object.assign(Object.assign({},e),{dontuseforce:false}))&&deployGit(e,true);t().info(r.green+"STEP: Deploying - Success");return true};var c=__nccwpck_require__(384);var u=__nccwpck_require__.n(c);var p=undefined&&undefined.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};const delay=e=>p(void 0,void 0,void 0,(function*(){if(typeof e.delay==="number"&&e.delay!==NaN){const sleep=e=>new Promise((t=>setTimeout(t,e)));yield sleep(e.delay*1e3)}return true}));const healthcheck=e=>p(void 0,void 0,void 0,(function*(){const n=yield u()(e.healthcheck);if(n.statusCode!==200){t().error(`${r.red}Status code of network request is not 200: Status code - ${n.statusCode}`);return true}if(e.checkstring&&e.checkstring!==n.body.toString()){t().error(r.red+"Failed to match the checkstring");return true}t().info(n.body.toString());return false}));const rollback=e=>{if(e.rollbackonhealthcheckfailed){(0,n.execSync)(`heroku rollback --app ${e.app_name}`,e.appdir?{cwd:e.appdir}:undefined);throw new Error("Health Check Failed. Error deploying Server. Deployment has been rolled back. Please check your logs on Heroku to try and diagnose the problem")}else{throw new Error("Health Check Failed. Error deploying Server. Please check your logs on Heroku to try and diagnose the problem")}};const performHealthCheck=e=>p(void 0,void 0,void 0,(function*(){t().debug(r.cyan+"STEP: Performing HealthCheck");if(e.healthcheck){(yield delay(e))&&(yield healthcheck(e))&&rollback(e)}t().info(r.green+"STEP: Performing HealthCheck - Success");return true}));var d=undefined&&undefined.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};(()=>d(void 0,void 0,void 0,(function*(){try{const e=getHerokuConfig();loginToHeroku(e)&&justLogin(e)&&configureGit(e)&&createProcfile(e)&&addRemote(e)&&addConfigVars(e)&&deploy(e)&&(yield performHealthCheck(e))}catch(t){e.setFailed("stderr"in t?t.stderr.toString():t.message.toString())}})))()})();module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{var __webpack_modules__={351:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(87));const s=r(278);function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+o.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const i="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=i+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${i}${escapeData(this.message)}`;return e}}function escapeData(e){return s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},186:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const s=r(351);const i=r(717);const a=r(278);const c=o(r(87));const u=o(r(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 r=a.toCommandValue(t);process.env[e]=r;const n=process.env["GITHUB_ENV"]||"";if(n){const t="_GitHubActionsFileCommandDelimeter_";const n=`${e}<<${t}${c.EOL}${r}${c.EOL}${t}`;i.issueCommand("ENV",n)}else{s.issueCommand("set-env",{name:e},r)}}t.exportVariable=exportVariable;function setSecret(e){s.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){i.issueCommand("PATH",e)}else{s.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${u.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}return r.trim()}t.getInput=getInput;function setOutput(e,t){s.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){s.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){s.issueCommand("debug",{},e)}t.debug=debug;function error(e){s.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){s.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+c.EOL)}t.info=info;function startGroup(e){s.issue("group",e)}t.startGroup=startGroup;function endGroup(){s.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return n(this,void 0,void 0,(function*(){startGroup(e);let r;try{r=yield t()}finally{endGroup()}return r}))}t.group=group;function saveState(e,t){s.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},717:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(747));const s=n(r(87));const i=r(278);function issueCommand(e,t){const r=process.env[`GITHUB_${e}`];if(!r){throw new Error(`Unable to find environment variable for file command ${e}`)}if(!o.existsSync(r)){throw new Error(`Missing file at path: ${r}`)}o.appendFileSync(r,`${i.toCommandValue(t)}${s.EOL}`,{encoding:"utf8"})}t.issueCommand=issueCommand},278:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});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},67:(e,t,r)=>{const n=r(755);e.exports=(e,t)=>new n(e,t)},755:(e,t,r)=>{const n=r(622);const o=r(605);const s=r(211);const i=r(191);const a=r(761);const{URL:c}=r(835);const u=r(386);const d=["gzip","deflate"];e.exports=class CentraRequest{constructor(e,t="GET"){this.url=typeof e==="string"?new c(e):e;this.method=t;this.data=null;this.sendDataAs=null;this.reqHeaders={};this.streamEnabled=false;this.compressionEnabled=false;this.timeoutTime=null;this.coreOptions={};this.resOptions={maxBuffer:50*1e6};return this}query(e,t){if(typeof e==="object"){Object.keys(e).forEach((t=>{this.url.searchParams.append(t,e[t])}))}else this.url.searchParams.append(e,t);return this}path(e){this.url.pathname=n.join(this.url.pathname,e);return this}body(e,t){this.sendDataAs=typeof e==="object"&&!t&&!Buffer.isBuffer(e)?"json":t?t.toLowerCase():"buffer";this.data=this.sendDataAs==="form"?i.stringify(e):this.sendDataAs==="json"?JSON.stringify(e):e;return this}header(e,t){if(typeof e==="object"){Object.keys(e).forEach((t=>{this.reqHeaders[t.toLowerCase()]=e[t]}))}else this.reqHeaders[e.toLowerCase()]=t;return this}timeout(e){this.timeoutTime=e;return this}option(e,t){this.coreOptions[e]=t;return this}stream(){this.streamEnabled=true;return this}compress(){this.compressionEnabled=true;if(!this.reqHeaders["accept-encoding"])this.reqHeaders["accept-encoding"]=d.join(", ");return this}send(){return new Promise(((e,t)=>{if(this.data){if(!this.reqHeaders.hasOwnProperty("content-type")){if(this.sendDataAs==="json"){this.reqHeaders["content-type"]="application/json"}else if(this.sendDataAs==="form"){this.reqHeaders["content-type"]="application/x-www-form-urlencoded"}}if(!this.reqHeaders.hasOwnProperty("content-length")){this.reqHeaders["content-length"]=Buffer.byteLength(this.data)}}const r=Object.assign({protocol:this.url.protocol,host:this.url.hostname,port:this.url.port,path:this.url.pathname+(this.url.search===null?"":this.url.search),method:this.method,headers:this.reqHeaders},this.coreOptions);let n;const resHandler=r=>{let n=r;if(this.compressionEnabled){if(r.headers["content-encoding"]==="gzip"){n=r.pipe(a.createGunzip())}else if(r.headers["content-encoding"]==="deflate"){n=r.pipe(a.createInflate())}}let o;if(this.streamEnabled){e(n)}else{o=new u(r,this.resOptions);n.on("error",(e=>{t(e)}));n.on("data",(e=>{o._addChunk(e);if(this.resOptions.maxBuffer!==null&&o.body.length>this.resOptions.maxBuffer){n.destroy();t("Received a response which was longer than acceptable when buffering. ("+this.body.length+" bytes)")}}));n.on("end",(()=>{e(o)}))}};if(this.url.protocol==="http:"){n=o.request(r,resHandler)}else if(this.url.protocol==="https:"){n=s.request(r,resHandler)}else throw new Error("Bad URL protocol: "+this.url.protocol);if(this.timeoutTime){n.setTimeout(this.timeoutTime,(()=>{n.abort();if(!this.streamEnabled){t(new Error("Timeout reached"))}}))}n.on("error",(e=>{t(e)}));if(this.data)n.write(this.data);n.end()}))}}},386:e=>{e.exports=class CentraResponse{constructor(e,t){this.coreRes=e;this.resOptions=t;this.body=Buffer.alloc(0);this.headers=e.headers;this.statusCode=e.statusCode}_addChunk(e){this.body=Buffer.concat([this.body,e])}async json(){return this.statusCode===204?null:JSON.parse(this.body)}async text(){return this.body.toString()}}},384:(e,t,r)=>{const{URL:n}=r(835);const o=r(67);const phin=async e=>{if(typeof e!=="string"){if(!e.hasOwnProperty("url")){throw new Error("Missing url option from options for request method.")}}const t=o(typeof e==="object"?e.url:e,e.method||"GET");if(e.headers)t.header(e.headers);if(e.stream)t.stream();if(e.timeout)t.timeout(e.timeout);if(e.data)t.body(e.data);if(e.form)t.body(e.form,"form");if(e.compression)t.compress();if(typeof e.core==="object"){Object.keys(e.core).forEach((r=>{t.option(r,e.core[r])}))}const r=await t.send();if(r.headers.hasOwnProperty("location")&&e.followRedirects){e.url=new n(r.headers["location"],e.url).toString();return await phin(e)}if(e.stream){r.stream=r;return r}else{r.coreRes.body=r.body;if(e.parse&&e.parse==="json"){r.coreRes.body=await r.json();return r.coreRes}else return r.coreRes}};phin.promisified=phin;phin.unpromisified=(e,t)=>{phin(e).then((e=>{if(t)t(null,e)})).catch((e=>{if(t)t(e,null)}))};phin.defaults=e=>async t=>{const r=typeof t==="string"?{url:t}:t;Object.keys(e).forEach((t=>{if(!r.hasOwnProperty(t)||r[t]===null){r[t]=e[t]}}));return await phin(r)};e.exports=phin},153:module=>{module.exports=eval("require")("dotenv")},747:e=>{"use strict";e.exports=require("fs")},605:e=>{"use strict";e.exports=require("http")},211:e=>{"use strict";e.exports=require("https")},87:e=>{"use strict";e.exports=require("os")},622:e=>{"use strict";e.exports=require("path")},191:e=>{"use strict";e.exports=require("querystring")},835:e=>{"use strict";e.exports=require("url")},761:e=>{"use strict";e.exports=require("zlib")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var r=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e].call(r.exports,r,r.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return r.exports}(()=>{__nccwpck_require__.n=e=>{var t=e&&e.__esModule?()=>e["default"]:()=>e;__nccwpck_require__.d(t,{a:t});return t}})();(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__={};(()=>{"use strict";__nccwpck_require__.r(__webpack_exports__);var e=__nccwpck_require__(186);const t={green:"",cyan:"",magenta:"",blue:"",red:""};const formatAppdir=e=>e[0]==="."&&e[1]==="/"?e.slice(2):e[0]==="/"?e.slice(1):e;const formatDockerBuildArgs=e=>{const t=e.split("\n").map((e=>`${e}="${process.env[e]}"`)).join(",");return t?"--arg "+t:""};const getHerokuConfig=()=>{e.debug(t.cyan+"STEP: Getting Heroku Config");const r={api_key:e.getInput("heroku_api_key"),email:e.getInput("heroku_email"),app_name:e.getInput("heroku_app_name"),buildpack:e.getInput("buildpack"),branch:e.getInput("branch"),dontuseforce:e.getInput("dontuseforce")==="false"?false:true,dontautocreate:e.getInput("dontautocreate")==="false"?false:true,usedocker:e.getInput("usedocker")==="false"?false:true,dockerHerokuProcessType:e.getInput("docker_heroku_process_type"),dockerBuildArgs:formatDockerBuildArgs(e.getInput("docker_build_args")),appdir:formatAppdir(e.getInput("appdir")),healthcheck:e.getInput("healthcheck"),checkstring:e.getInput("checkstring"),delay:parseInt(e.getInput("delay")),procfile:e.getInput("procfile"),rollbackonhealthcheckfailed:e.getInput("rollbackonhealthcheckfailed")==="false"?false:true,env_file:e.getInput("env_file"),justlogin:e.getInput("justlogin")==="false"?false:true,region:e.getInput("region"),stack:e.getInput("stack"),team:e.getInput("team")};e.info(t.green+"STEP: Getting Heroku Config - Success");return r};const justLogin=e=>!e.justlogin;const r=require("child_process");const createCatFile=({email:e,api_key:t})=>`cat >~/.netrc <{e.debug(t.cyan+"STEP: Login to Heroku");(0,r.execSync)(createCatFile(n));if(n.usedocker){(0,r.execSync)("heroku container:login")}e.info(t.green+"STEP: Login to Heroku - Success");return true};const configureUserAndCommit=e=>{(0,r.execSync)(`git config user.name "Heroku-Deploy"`);(0,r.execSync)(`git config user.email "${e.email}"`);if((0,r.execSync)("git status --porcelain").toString().trim()){(0,r.execSync)('git add -A && git commit -m "Commited changes from previous actions"')}return true};const unshallowRepo=e=>{if(e.usedocker){return true}if((0,r.execSync)("git rev-parse --is-shallow-repository").toString().trim()==="true"){(0,r.execSync)("git fetch --prune --unshallow")}return true};const configureGit=r=>{e.debug(t.cyan+"STEP: Configuring git");configureUserAndCommit(r)&&unshallowRepo(r);e.info(t.green+"STEP: Configuring git - Success");return true};var n=__nccwpck_require__(747);var o=__nccwpck_require__.n(n);var s=__nccwpck_require__(622);var i=__nccwpck_require__.n(s);const createProcfile=n=>{if(n.procfile){e.debug(t.cyan+"STEP: Creating Procfile");o().writeFileSync(i().join(n.appdir,"Procfile"),n.procfile);(0,r.execSync)(`git add -A && git commit -m "Added Procfile"`);e.info(t.green+"STEP: Creating Procfile - Success")}return true};const addRemote=n=>{e.debug(t.cyan+"STEP: Adding Remote");try{(0,r.execSync)("heroku git:remote --app "+n.app_name);e.debug("Added git remote heroku")}catch(e){if(n.dontautocreate){throw e}(0,r.execSync)("heroku create "+n.app_name+(n.buildpack?" --buildpack "+n.buildpack:"")+(n.region?" --region "+n.region:"")+(n.stack?" --stack "+n.stack:"")+(n.team?" --team "+n.team:""))}e.info(t.green+"STEP: Adding Remote - Success");return true};const addVarsFromEnv=e=>{const t=[...e];for(let e in process.env){if(e.startsWith("HD_")){t.push(e.substring(3)+"='"+process.env[e]+"'")}}return t};const addVarsFromEnvFile=(e,t)=>{if(e.env_file){const r=o().readFileSync(i().join(e.appdir,e.env_file),"utf8");const n=__nccwpck_require__(153).parse(r);const s=[];for(let e in n){s.push(e+"="+n[e])}return[...t,...s]}return t};const addConfigVars=n=>{e.debug(t.cyan+"STEP: Adding Configuration Variables from env and envfile");const o=addVarsFromEnv([]);const s=addVarsFromEnvFile(n,o);if(s.length!==0){(0,r.execSync)(`heroku config:set --app=${n.app_name} ${s.join(" ")}`)}e.info(t.green+"STEP: Adding Configuration Variables from env and envfile - Success");return true};const deployDocker=e=>{if(e.usedocker){(0,r.execSync)(`heroku container:push ${e.dockerHerokuProcessType} --app ${e.app_name} ${e.dockerBuildArgs}`,e.appdir?{cwd:e.appdir}:undefined);(0,r.execSync)(`heroku container:release ${e.dockerHerokuProcessType} --app ${e.app_name}`,e.appdir?{cwd:e.appdir}:undefined);return false}return true};const fixRemoteBranch=e=>{let t=(0,r.execSync)("git remote show heroku | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g'").toString().trim();if(t==="master"){(0,r.execSync)("heroku plugins:install heroku-repo");(0,r.execSync)("heroku repo:reset -a "+e.app_name)}return true};const deployGit=(n,o=false)=>{const s=!n.dontuseforce?"--force":"";const i=n.appdir?`\`git subtree split --prefix=${n.appdir} ${n.branch}\``:n.branch;try{(0,r.execSync)(`git push ${s} heroku ${i}:refs/head/main`,{maxBuffer:104857600})}catch(r){if(o){throw r}else{e.error(t.red+("stderr"in r?r.stderr.toString():r.message.toString()));return true}}return false};const deploy=r=>{e.debug(t.cyan+"STEP: Deploying");deployDocker(r)&&fixRemoteBranch(r)&&deployGit(Object.assign(Object.assign({},r),{dontuseforce:false}))&&deployGit(r,true);e.info(t.green+"STEP: Deploying - Success");return true};var a=__nccwpck_require__(384);var c=__nccwpck_require__.n(a);var u=undefined&&undefined.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};const delay=e=>u(void 0,void 0,void 0,(function*(){if(typeof e.delay==="number"&&e.delay!==NaN){const sleep=e=>new Promise((t=>setTimeout(t,e)));yield sleep(e.delay*1e3)}return true}));const healthcheck=r=>u(void 0,void 0,void 0,(function*(){const n=yield c()(r.healthcheck);if(n.statusCode!==200){e.error(`${t.red}Status code of network request is not 200: Status code - ${n.statusCode}`);return true}if(r.checkstring&&r.checkstring!==n.body.toString()){e.error(t.red+"Failed to match the checkstring");return true}e.info(n.body.toString());return false}));const rollback=e=>{if(e.rollbackonhealthcheckfailed){(0,r.execSync)(`heroku rollback --app ${e.app_name}`,e.appdir?{cwd:e.appdir}:undefined);throw new Error("Health Check Failed. Error deploying Server. Deployment has been rolled back. Please check your logs on Heroku to try and diagnose the problem")}else{throw new Error("Health Check Failed. Error deploying Server. Please check your logs on Heroku to try and diagnose the problem")}};const performHealthCheck=r=>u(void 0,void 0,void 0,(function*(){e.debug(t.cyan+"STEP: Performing HealthCheck");if(r.healthcheck){(yield delay(r))&&(yield healthcheck(r))&&rollback(r)}e.info(t.green+"STEP: Performing HealthCheck - Success");return true}));var d=undefined&&undefined.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};(()=>d(void 0,void 0,void 0,(function*(){try{const e=getHerokuConfig();loginToHeroku(e)&&justLogin(e)&&configureGit(e)&&createProcfile(e)&&addRemote(e)&&addConfigVars(e)&&deploy(e)&&(yield performHealthCheck(e))}catch(t){e.setFailed("stderr"in t?t.stderr.toString():t.message.toString())}})))()})();module.exports=__webpack_exports__})(); \ No newline at end of file