From 03ca72bfbe67e30200683b999d49ba09e436d20f Mon Sep 17 00:00:00 2001 From: Balaga Gayatri Date: Mon, 14 Jun 2021 12:53:44 +0530 Subject: [PATCH] Adding commit message to zipDeploy payload (#127) * added commit message to zipDeploy payload * added commit message to zipDeploy payload * Added input field to the action.yml * removed node_modules * removed nodemodules * Removed node_modules from source code * Users/balaga gayatri/commit message fix (#125) * added commit message to zipDeploy payload * added commit message to zipDeploy payload * Added input field to the action.yml * removed node_modules * removed nodemodules * Removed node_modules from source code * removed taking input through action.yml * removed node_modules after testing * Users/balaga gayatri/commit message fix (#126) * added commit message to zipDeploy payload without action.yml input * Update action.yml * Removing formatting * removed whitespaces * adding node_modules * adding node_modules * debugging for head_commit message * debugging for head_commit message * debugging for head_commit message * debugging for head_commit message * Added empty commit message for non push github event * Update main.ts * Update main.ts * Users/balaga gayatri/commit message fix (#131) * Added empty commit message for non push github event * changes * added node_modules * node_modules * updated lib file * whitespace changes --- .../Providers/WebAppDeploymentProvider.js | 8 +- lib/actionparameters.js | 8 + package-lock.json | 394 +++++++++++++++--- package.json | 1 + .../Providers/WebAppDeploymentProvider.ts | 8 +- src/actionparameters.ts | 277 ++++++------ src/main.ts | 6 +- 7 files changed, 490 insertions(+), 212 deletions(-) diff --git a/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js b/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js index 6de42af57..38ff172ce 100644 --- a/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js +++ b/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js @@ -34,25 +34,25 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp case packageUtility_1.PackageType.war: core.debug("Initiated deployment via kudu service for webapp war package : " + webPackage); var warName = utility.getFileNameFromPath(webPackage, ".war"); - this.deploymentID = yield this.kuduServiceUtility.deployUsingWarDeploy(webPackage, { slotName: this.actionParams.slotName }, warName); + this.deploymentID = yield this.kuduServiceUtility.deployUsingWarDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage: this.actionParams.commitMessage }, warName); break; case packageUtility_1.PackageType.jar: core.debug("Initiated deployment via kudu service for webapp jar package : " + webPackage); let folderPath = yield utility.generateTemporaryFolderForDeployment(false, webPackage, packageUtility_1.PackageType.jar); let output = yield utility.archiveFolderForDeployment(false, folderPath); webPackage = output.webDeployPkg; - this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName }); + this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage: this.actionParams.commitMessage }); break; case packageUtility_1.PackageType.folder: let tempPackagePath = utility.generateTemporaryFolderOrZipPath(`${process.env.RUNNER_TEMP}`, false); webPackage = (yield zipUtility.archiveFolder(webPackage, "", tempPackagePath)); core.debug("Compressed folder into zip " + webPackage); core.debug("Initiated deployment via kudu service for webapp package : " + webPackage); - this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName }); + this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage: this.actionParams.commitMessage }); break; case packageUtility_1.PackageType.zip: core.debug("Initiated deployment via kudu service for webapp package : " + webPackage); - this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName }); + this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage: this.actionParams.commitMessage }); break; default: throw new Error('Invalid App Service package or folder path provided: ' + webPackage); diff --git a/lib/actionparameters.js b/lib/actionparameters.js index 1a2edfbde..9ed3d48b3 100644 --- a/lib/actionparameters.js +++ b/lib/actionparameters.js @@ -8,6 +8,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); +const github = require('@actions/github'); var WebAppKind; (function (WebAppKind) { WebAppKind[WebAppKind["Windows"] = 0] = "Windows"; @@ -31,6 +32,7 @@ class ActionParameters { this._images = core.getInput('images'); this._multiContainerConfigFile = core.getInput('configuration-file'); this._startupCommand = core.getInput('startup-command'); + this._commitMessage = github.context.eventName === 'push' ? github.context.payload.head_commit.message : ""; this._endpoint = endpoint; } static getActionParams(endpoint) { @@ -42,6 +44,12 @@ class ActionParameters { get appName() { return this._appName; } + get commitMessage() { + return this._commitMessage; + } + set commitMessage(commitMessage) { + this._commitMessage = commitMessage; + } get packageInput() { return this._packageInput; } diff --git a/package-lock.json b/package-lock.json index 954202a0a..f002df929 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,9 @@ "license": "MIT", "dependencies": { "@actions/core": "^1.2.6", + "@actions/github": "^4.0.0", "actions-secret-parser": "^1.0.3", - "azure-actions-appservice-rest": "^1.3.0", + "azure-actions-appservice-rest": "^1.3.1", "azure-actions-utility": "^1.0.3", "azure-actions-webclient": "^1.1.0" }, @@ -36,6 +37,25 @@ "@actions/io": "^1.0.1" } }, + "node_modules/@actions/github": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-4.0.0.tgz", + "integrity": "sha512-Ej/Y2E+VV6sR9X7pWL5F3VgEWrABaT292DRqRU6R4hnQjPtC/zD3nagxVdXWiRQvYDh8kHXo7IDmG42eJ/dOMA==", + "dependencies": { + "@actions/http-client": "^1.0.8", + "@octokit/core": "^3.0.0", + "@octokit/plugin-paginate-rest": "^2.2.3", + "@octokit/plugin-rest-endpoint-methods": "^4.0.0" + } + }, + "node_modules/@actions/http-client": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", + "dependencies": { + "tunnel": "0.0.6" + } + }, "node_modules/@actions/io": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.1.tgz", @@ -77,12 +97,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/core/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, "node_modules/@babel/core/node_modules/semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -174,12 +188,6 @@ "lodash": "^4.17.19" } }, - "node_modules/@babel/helper-module-transforms/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, "node_modules/@babel/helper-optimise-call-expression": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz", @@ -455,12 +463,6 @@ "lodash": "^4.17.19" } }, - "node_modules/@babel/traverse/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, "node_modules/@babel/types": { "version": "7.11.5", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.11.5.tgz", @@ -472,12 +474,6 @@ "to-fast-properties": "^2.0.0" } }, - "node_modules/@babel/types/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, "node_modules/@bcoe/v8-coverage": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", @@ -779,6 +775,125 @@ "node": ">= 8.3" } }, + "node_modules/@octokit/auth-token": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.5.tgz", + "integrity": "sha512-BpGYsPgJt05M7/L/5FoE1PiAbdxXFZkX/3kDYcsvd1v6UhlnE5e96dTDr0ezX/EFwciQxf3cNV0loipsURU+WA==", + "dependencies": { + "@octokit/types": "^6.0.3" + } + }, + "node_modules/@octokit/core": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.4.0.tgz", + "integrity": "sha512-6/vlKPP8NF17cgYXqucdshWqmMZGXkuvtcrWCgU5NOI0Pl2GjlmZyWgBMrU8zJ3v2MJlM6++CiB45VKYmhiWWg==", + "dependencies": { + "@octokit/auth-token": "^2.4.4", + "@octokit/graphql": "^4.5.8", + "@octokit/request": "^5.4.12", + "@octokit/request-error": "^2.0.5", + "@octokit/types": "^6.0.3", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + } + }, + "node_modules/@octokit/endpoint": { + "version": "6.0.11", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.11.tgz", + "integrity": "sha512-fUIPpx+pZyoLW4GCs3yMnlj2LfoXTWDUVPTC4V3MUEKZm48W+XYpeWSZCv+vYF1ZABUm2CqnDVf1sFtIYrj7KQ==", + "dependencies": { + "@octokit/types": "^6.0.3", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + } + }, + "node_modules/@octokit/endpoint/node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@octokit/graphql": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.6.1.tgz", + "integrity": "sha512-2lYlvf4YTDgZCTXTW4+OX+9WTLFtEUc6hGm4qM1nlZjzxj+arizM4aHWzBVBCxY9glh7GIs0WEuiSgbVzv8cmA==", + "dependencies": { + "@octokit/request": "^5.3.0", + "@octokit/types": "^6.0.3", + "universal-user-agent": "^6.0.0" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-6.0.0.tgz", + "integrity": "sha512-CnDdK7ivHkBtJYzWzZm7gEkanA7gKH6a09Eguz7flHw//GacPJLmkHA3f3N++MJmlxD1Fl+mB7B32EEpSCwztQ==" + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "2.13.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.13.3.tgz", + "integrity": "sha512-46lptzM9lTeSmIBt/sVP/FLSTPGx6DCzAdSX3PfeJ3mTf4h9sGC26WpaQzMEq/Z44cOcmx8VsOhO+uEgE3cjYg==", + "dependencies": { + "@octokit/types": "^6.11.0" + }, + "peerDependencies": { + "@octokit/core": ">=2" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "4.15.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.15.0.tgz", + "integrity": "sha512-1AF9GM/Ywk8ukUM5seDRj286GdFpdfsHeOrOPBV2rVtRN7MQNzRIcw8W5sb4JPerjQ0WcRRwAwQyufg64BxJkA==", + "dependencies": { + "@octokit/types": "^6.13.0", + "deprecation": "^2.3.1" + }, + "peerDependencies": { + "@octokit/core": ">=3" + } + }, + "node_modules/@octokit/request": { + "version": "5.4.14", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.14.tgz", + "integrity": "sha512-VkmtacOIQp9daSnBmDI92xNIeLuSRDOIuplp/CJomkvzt7M18NXgG044Cx/LFKLgjKt9T2tZR6AtJayba9GTSA==", + "dependencies": { + "@octokit/endpoint": "^6.0.1", + "@octokit/request-error": "^2.0.0", + "@octokit/types": "^6.7.1", + "deprecation": "^2.0.0", + "is-plain-object": "^5.0.0", + "node-fetch": "^2.6.1", + "once": "^1.4.0", + "universal-user-agent": "^6.0.0" + } + }, + "node_modules/@octokit/request-error": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.5.tgz", + "integrity": "sha512-T/2wcCFyM7SkXzNoyVNWjyVlUwBvW3igM3Btr/eKYiPmucXTtkxt2RBsf6gn3LTzaLSLTQtNmvg+dGsOxQrjZg==", + "dependencies": { + "@octokit/types": "^6.0.3", + "deprecation": "^2.0.0", + "once": "^1.4.0" + } + }, + "node_modules/@octokit/request/node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@octokit/types": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.13.0.tgz", + "integrity": "sha512-W2J9qlVIU11jMwKHUp5/rbVUeErqelCsO5vW5PKNb7wAXQVUz87Rc+imjlEvpvbH8yUb+KHmv8NEjVZdsdpyxA==", + "dependencies": { + "@octokit/openapi-types": "^6.0.0" + } + }, "node_modules/@sinonjs/commons": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.1.tgz", @@ -1142,6 +1257,11 @@ "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", "dev": true }, + "node_modules/array-filter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-1.0.0.tgz", + "integrity": "sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=" + }, "node_modules/array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -1464,6 +1584,11 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/before-after-hook": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz", + "integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw==" + }, "node_modules/binary": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", @@ -1474,9 +1599,9 @@ } }, "node_modules/bl": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", - "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", "dependencies": { "readable-stream": "^2.3.5", "safe-buffer": "^5.1.1" @@ -2101,6 +2226,11 @@ "node": ">=0.4.0" } }, + "node_modules/deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -4317,9 +4447,9 @@ } }, "node_modules/lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" }, "node_modules/lodash.memoize": { "version": "4.1.2", @@ -4538,6 +4668,14 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node_modules/node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "engines": { + "node": "4.x || >=6.0.0" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -5234,12 +5372,6 @@ "node": ">=0.10.0" } }, - "node_modules/request-promise-core/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, "node_modules/request-promise-native": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.9.tgz", @@ -6487,6 +6619,11 @@ "node": ">=0.10.0" } }, + "node_modules/universal-user-agent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", + "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" + }, "node_modules/unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -6932,6 +7069,25 @@ "@actions/io": "^1.0.1" } }, + "@actions/github": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-4.0.0.tgz", + "integrity": "sha512-Ej/Y2E+VV6sR9X7pWL5F3VgEWrABaT292DRqRU6R4hnQjPtC/zD3nagxVdXWiRQvYDh8kHXo7IDmG42eJ/dOMA==", + "requires": { + "@actions/http-client": "^1.0.8", + "@octokit/core": "^3.0.0", + "@octokit/plugin-paginate-rest": "^2.2.3", + "@octokit/plugin-rest-endpoint-methods": "^4.0.0" + } + }, + "@actions/http-client": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", + "requires": { + "tunnel": "0.0.6" + } + }, "@actions/io": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.1.tgz", @@ -7590,6 +7746,117 @@ "chalk": "^3.0.0" } }, + "@octokit/auth-token": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.5.tgz", + "integrity": "sha512-BpGYsPgJt05M7/L/5FoE1PiAbdxXFZkX/3kDYcsvd1v6UhlnE5e96dTDr0ezX/EFwciQxf3cNV0loipsURU+WA==", + "requires": { + "@octokit/types": "^6.0.3" + } + }, + "@octokit/core": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.4.0.tgz", + "integrity": "sha512-6/vlKPP8NF17cgYXqucdshWqmMZGXkuvtcrWCgU5NOI0Pl2GjlmZyWgBMrU8zJ3v2MJlM6++CiB45VKYmhiWWg==", + "requires": { + "@octokit/auth-token": "^2.4.4", + "@octokit/graphql": "^4.5.8", + "@octokit/request": "^5.4.12", + "@octokit/request-error": "^2.0.5", + "@octokit/types": "^6.0.3", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/endpoint": { + "version": "6.0.11", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.11.tgz", + "integrity": "sha512-fUIPpx+pZyoLW4GCs3yMnlj2LfoXTWDUVPTC4V3MUEKZm48W+XYpeWSZCv+vYF1ZABUm2CqnDVf1sFtIYrj7KQ==", + "requires": { + "@octokit/types": "^6.0.3", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + }, + "dependencies": { + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + } + } + }, + "@octokit/graphql": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.6.1.tgz", + "integrity": "sha512-2lYlvf4YTDgZCTXTW4+OX+9WTLFtEUc6hGm4qM1nlZjzxj+arizM4aHWzBVBCxY9glh7GIs0WEuiSgbVzv8cmA==", + "requires": { + "@octokit/request": "^5.3.0", + "@octokit/types": "^6.0.3", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/openapi-types": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-6.0.0.tgz", + "integrity": "sha512-CnDdK7ivHkBtJYzWzZm7gEkanA7gKH6a09Eguz7flHw//GacPJLmkHA3f3N++MJmlxD1Fl+mB7B32EEpSCwztQ==" + }, + "@octokit/plugin-paginate-rest": { + "version": "2.13.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.13.3.tgz", + "integrity": "sha512-46lptzM9lTeSmIBt/sVP/FLSTPGx6DCzAdSX3PfeJ3mTf4h9sGC26WpaQzMEq/Z44cOcmx8VsOhO+uEgE3cjYg==", + "requires": { + "@octokit/types": "^6.11.0" + } + }, + "@octokit/plugin-rest-endpoint-methods": { + "version": "4.15.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.15.0.tgz", + "integrity": "sha512-1AF9GM/Ywk8ukUM5seDRj286GdFpdfsHeOrOPBV2rVtRN7MQNzRIcw8W5sb4JPerjQ0WcRRwAwQyufg64BxJkA==", + "requires": { + "@octokit/types": "^6.13.0", + "deprecation": "^2.3.1" + } + }, + "@octokit/request": { + "version": "5.4.14", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.14.tgz", + "integrity": "sha512-VkmtacOIQp9daSnBmDI92xNIeLuSRDOIuplp/CJomkvzt7M18NXgG044Cx/LFKLgjKt9T2tZR6AtJayba9GTSA==", + "requires": { + "@octokit/endpoint": "^6.0.1", + "@octokit/request-error": "^2.0.0", + "@octokit/types": "^6.7.1", + "deprecation": "^2.0.0", + "is-plain-object": "^5.0.0", + "node-fetch": "^2.6.1", + "once": "^1.4.0", + "universal-user-agent": "^6.0.0" + }, + "dependencies": { + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + } + } + }, + "@octokit/request-error": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.5.tgz", + "integrity": "sha512-T/2wcCFyM7SkXzNoyVNWjyVlUwBvW3igM3Btr/eKYiPmucXTtkxt2RBsf6gn3LTzaLSLTQtNmvg+dGsOxQrjZg==", + "requires": { + "@octokit/types": "^6.0.3", + "deprecation": "^2.0.0", + "once": "^1.4.0" + } + }, + "@octokit/types": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.13.0.tgz", + "integrity": "sha512-W2J9qlVIU11jMwKHUp5/rbVUeErqelCsO5vW5PKNb7wAXQVUz87Rc+imjlEvpvbH8yUb+KHmv8NEjVZdsdpyxA==", + "requires": { + "@octokit/openapi-types": "^6.0.0" + } + }, "@sinonjs/commons": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.1.tgz", @@ -7912,8 +8179,7 @@ "dev": true }, "array-filter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-1.0.0.tgz", + "version": "https://registry.npmjs.org/array-filter/-/array-filter-1.0.0.tgz", "integrity": "sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=" }, "array-unique": { @@ -8190,6 +8456,11 @@ "tweetnacl": "^0.14.3" } }, + "before-after-hook": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz", + "integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw==" + }, "binary": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", @@ -8732,6 +9003,11 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, + "deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, "detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -9632,30 +9908,6 @@ "has-symbols": "^1.0.1" } }, - "is-typed-array": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.5.tgz", - "integrity": "sha512-S+GRDgJlR3PyEbsX/Fobd9cqpZBuvUS+8asRqYDMLCb2qMzt1oz5m5oxQCxOgUDxiWsOVNi4yaF+/uvdlHlYug==", - "requires": { - "available-typed-arrays": "^1.0.2", - "call-bind": "^1.0.2", - "es-abstract": "^1.18.0-next.2", - "foreach": "^2.0.5", - "has-symbols": "^1.0.1" - } - }, - "is-typed-array": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.5.tgz", - "integrity": "sha512-S+GRDgJlR3PyEbsX/Fobd9cqpZBuvUS+8asRqYDMLCb2qMzt1oz5m5oxQCxOgUDxiWsOVNi4yaF+/uvdlHlYug==", - "requires": { - "available-typed-arrays": "^1.0.2", - "call-bind": "^1.0.2", - "es-abstract": "^1.18.0-next.2", - "foreach": "^2.0.5", - "has-symbols": "^1.0.1" - } - }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -10692,6 +10944,11 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -12269,6 +12526,11 @@ "set-value": "^2.0.1" } }, + "universal-user-agent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", + "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -12576,9 +12838,9 @@ "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, "y18n": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", - "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "dev": true }, "yargs": { diff --git a/package.json b/package.json index 8ff4d5f3c..b17daf8e2 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ }, "dependencies": { "@actions/core": "^1.2.6", + "@actions/github": "^4.0.0", "actions-secret-parser": "^1.0.3", "azure-actions-appservice-rest": "^1.3.1", "azure-actions-utility": "^1.0.3", diff --git a/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts b/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts index 0da14307c..20e4c726f 100644 --- a/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts +++ b/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts @@ -23,7 +23,7 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { core.debug("Initiated deployment via kudu service for webapp war package : "+ webPackage); var warName = utility.getFileNameFromPath(webPackage, ".war"); this.deploymentID = await this.kuduServiceUtility.deployUsingWarDeploy(webPackage, - { slotName: this.actionParams.slotName }, warName); + { slotName: this.actionParams.slotName , commitMessage: this.actionParams.commitMessage }, warName); break; case PackageType.jar: @@ -31,7 +31,7 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { let folderPath = await utility.generateTemporaryFolderForDeployment(false, webPackage, PackageType.jar); let output = await utility.archiveFolderForDeployment(false, folderPath); webPackage = output.webDeployPkg; - this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName }); + this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName , commitMessage:this.actionParams.commitMessage }); break; case PackageType.folder: @@ -39,12 +39,12 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { webPackage = await zipUtility.archiveFolder(webPackage, "", tempPackagePath) as string; core.debug("Compressed folder into zip " + webPackage); core.debug("Initiated deployment via kudu service for webapp package : "+ webPackage); - this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName }); + this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage: this.actionParams.commitMessage }); break; case PackageType.zip: core.debug("Initiated deployment via kudu service for webapp package : "+ webPackage); - this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName }); + this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName , commitMessage: this.actionParams.commitMessage}); break; default: diff --git a/src/actionparameters.ts b/src/actionparameters.ts index 9310cd335..9e69d3e42 100644 --- a/src/actionparameters.ts +++ b/src/actionparameters.ts @@ -1,135 +1,142 @@ -import * as core from '@actions/core'; - -import { IAuthorizer } from "azure-actions-webclient/Authorizer/IAuthorizer"; -import { Package } from 'azure-actions-utility/packageUtility'; - -export enum WebAppKind { - Windows, - Linux, - WindowsContainer, - LinuxContainer -}; - -export const appKindMap = new Map([ - [ 'app', WebAppKind.Windows ], - [ 'app,linux', WebAppKind.Linux ], - [ 'app,container,windows', WebAppKind.WindowsContainer ], - [ 'app,linux,container', WebAppKind.LinuxContainer ] -]); - -export class ActionParameters { - private static actionparams: ActionParameters; - private _appName: string; - private _packageInput: string; - private _package: Package; - private _images: string; - private _resourceGroupName?: string; - private _kind: WebAppKind; - private _realKind: string; - private _endpoint: IAuthorizer; - private _publishProfileContent: string; - private _slotName: string; - private _multiContainerConfigFile?: string; - private _startupCommand: string; - private _isMultiContainer: boolean; - private _isLinux: boolean; - - private constructor(endpoint: IAuthorizer) { - this._publishProfileContent = core.getInput('publish-profile'); - this._appName = core.getInput('app-name'); - this._slotName = core.getInput('slot-name'); - this._packageInput = core.getInput('package'); - this._images = core.getInput('images'); - this._multiContainerConfigFile = core.getInput('configuration-file'); - this._startupCommand = core.getInput('startup-command'); - this._endpoint = endpoint; - } - - public static getActionParams(endpoint?: IAuthorizer) { - if (!this.actionparams) { - this.actionparams = new ActionParameters(!!endpoint ? endpoint : null); - } - - return this.actionparams; - } - - public get appName() { - return this._appName; - } - - public get packageInput() { - return this._packageInput; - } - - public get package() { - return this._package; - } - - public set package(appPackage: Package) { - this._package = appPackage; - } - - public get images() { - return this._images; - } - - public get resourceGroupName() { - return this._resourceGroupName; - } - - public set resourceGroupName(rg: string) { - this._resourceGroupName = rg; - } - - public get kind() { - return this._kind; - } - - public set kind(kind: WebAppKind) { - this._kind = kind; - } - - public get realKind() { - return this._realKind; - } - - public set realKind(kind: string) { - this._realKind = kind; - } - - public get endpoint() { - return this._endpoint; - } - - public get publishProfileContent() { - return this._publishProfileContent; - } - - public get slotName() { - return this._slotName; - } - - public get isMultiContainer() { - return this._isMultiContainer; - } - - public set isMultiContainer(isMultiCont: boolean) { - this._isMultiContainer = isMultiCont; - } - - public get isLinux(): boolean { - return this._isLinux; - } - - public set isLinux(isLin: boolean) { - this._isLinux = isLin; - } - - public get startupCommand() { - return this._startupCommand; - } - - public get multiContainerConfigFile() { - return this._multiContainerConfigFile; - } -} \ No newline at end of file +import * as core from '@actions/core'; +import { IAuthorizer } from "azure-actions-webclient/Authorizer/IAuthorizer"; +import { Package } from 'azure-actions-utility/packageUtility'; +const github = require('@actions/github'); + +export enum WebAppKind { + Windows, + Linux, + WindowsContainer, + LinuxContainer +}; + +export const appKindMap = new Map([ + [ 'app', WebAppKind.Windows ], + [ 'app,linux', WebAppKind.Linux ], + [ 'app,container,windows', WebAppKind.WindowsContainer ], + [ 'app,linux,container', WebAppKind.LinuxContainer ] +]); + +export class ActionParameters { + private static actionparams: ActionParameters; + private _appName: string; + private _packageInput: string; + private _package: Package; + private _images: string; + private _resourceGroupName?: string; + private _kind: WebAppKind; + private _realKind: string; + private _endpoint: IAuthorizer; + private _publishProfileContent: string; + private _slotName: string; + private _multiContainerConfigFile?: string; + private _startupCommand: string; + private _isMultiContainer: boolean; + private _isLinux: boolean; + private _commitMessage: string; + + private constructor(endpoint: IAuthorizer) { + this._publishProfileContent = core.getInput('publish-profile'); + this._appName = core.getInput('app-name'); + this._slotName = core.getInput('slot-name'); + this._packageInput = core.getInput('package'); + this._images = core.getInput('images'); + this._multiContainerConfigFile = core.getInput('configuration-file'); + this._startupCommand = core.getInput('startup-command'); + this._commitMessage = github.context.eventName === 'push'? github.context.payload.head_commit.message: ""; + this._endpoint = endpoint; + } + + public static getActionParams(endpoint?: IAuthorizer) { + if (!this.actionparams) { + this.actionparams = new ActionParameters(!!endpoint ? endpoint : null); + } + + return this.actionparams; + } + public get appName() { + return this._appName; + } + public get commitMessage(){ + return this._commitMessage; + } + public set commitMessage(commitMessage: string) { + this._commitMessage = commitMessage; + } + public get packageInput() { + return this._packageInput; + } + + public get package() { + return this._package; + } + + public set package(appPackage: Package) { + this._package = appPackage; + } + + public get images() { + return this._images; + } + + public get resourceGroupName() { + return this._resourceGroupName; + } + + public set resourceGroupName(rg: string) { + this._resourceGroupName = rg; + } + + public get kind() { + return this._kind; + } + + public set kind(kind: WebAppKind) { + this._kind = kind; + } + + public get realKind() { + return this._realKind; + } + + public set realKind(kind: string) { + this._realKind = kind; + } + + public get endpoint() { + return this._endpoint; + } + + public get publishProfileContent() { + return this._publishProfileContent; + } + + public get slotName() { + return this._slotName; + } + + public get isMultiContainer() { + return this._isMultiContainer; + } + + public set isMultiContainer(isMultiCont: boolean) { + this._isMultiContainer = isMultiCont; + } + + public get isLinux(): boolean { + return this._isLinux; + } + + public set isLinux(isLin: boolean) { + this._isLinux = isLin; + } + + public get startupCommand() { + return this._startupCommand; + } + + public get multiContainerConfigFile() { + return this._multiContainerConfigFile; + } + +} diff --git a/src/main.ts b/src/main.ts index 256243e50..36f4ed67d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,9 +36,9 @@ export async function main() { // Validate action inputs let validator = await ValidatorFactory.getValidator(type); await validator.validate(); - + var deploymentProvider = DeploymentProviderFactory.getDeploymentProvider(type); - + core.debug("Predeployment Step Started"); await deploymentProvider.PreDeploymentStep(); @@ -61,4 +61,4 @@ export async function main() { } } -main(); \ No newline at end of file +main();