From c7b34876bb8d7f7268ef2a5e3e479afd82a663a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 6 Dec 2022 16:47:10 -0500 Subject: [PATCH] v4 new release (#268) * Add missing API switch for GHES (#200) * Vidya reddy/prettier code (#203) * switch none deployment strategy to basic (#204) * switch none deployment strategy to basic * update readme * update deployment strategy fallthrough logic * comment fixed * add disclaimer for basic strategy only supporting deploy action * Hari/beautify logs (#206) * Logging changes for deploy * Logging Changes with group * format check changes * Add ncc build to build script (#208) Co-authored-by: Vidya Reddy * Logging Changes for Promote, Reject actions (#207) * add clean function (#211) * Added Traffic split annotations (#215) * Added Traffic split annotations * traffic split - blueGreen deployment * traffic split - canary deployment * Traffic split annotations - canary deployment * updated Readme and action.yml * Traffic split - canary deployment * clean code * Clean code * Clean code * Create annotation object * Updated Readme and action.yml * Spelling correction Co-authored-by: Vidya Reddy * Swap annotation key to actions.github.com prefix (#216) * Private Cluster functionality (#214) * Fixed Blue/Green Strategy Ingress Route-Method Glitch (#217) * Added some tests, not sure what else to try but gonna think of more examples * forgot some files * reverted package-lock.json * Added empty dir test * Cleaned up some extra spaces * Add node modules and compiled JavaScript from main * forgot to actually include functionality * removed unnecessary files * Update .gitignore * Update .gitignore * Update .gitignore * thx david * renamed searchFilesRec * integrations test fix * added examples to README * added note about depth * added additional note * removed ticks * changed version string * removed conflict on readme * Added tests for bluegreen helper and resolved issue with ingress not being read correctly, still have to figure out why new services aren't showing up * resolved services name issue * looks functional, beginning refactor now * refactored deploy methods for type error * Removed refactor comments * prettier * implemented Oliver's feedback * prettier * added optional chaining operator * removed refactor comment Co-authored-by: Jaiveer Katariya Co-authored-by: Oliver King Co-authored-by: Jaiveer Katariya * Blue/Green Refactor (#229) * fresh new branch * Added coverage to gitignore Signed-off-by: Jaiveer Katariya * reverted package-lock.json Signed-off-by: Jaiveer Katariya Co-authored-by: Jaiveer Katariya * consider slashes while cleaning labels (#231) fix prettier format check errors * Fix README.md typo (#235) * Bump @actions/core from 1.9.0 to 1.9.1 (#233) Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.9.0 to 1.9.1. - [Release notes](https://github.com/actions/toolkit/releases) - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) --- updated-dependencies: - dependency-name: "@actions/core" dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add permissions to README.md (#236) * Add permissions to README.md * remove space * prettier * remove extra changes * fix spacing * Add the bug report and feature request form (#237) * Added the bug report and feature request form * updated the url * Fix issue form (#238) * Fix description about baseline-and-canary-replicas (#241) * Resolved issue with Canary deploy (#247) * Added support message (#249) * Deploy with Manifests from URLs (#251) * added functionality, need to add/modify existing tests * added tests * updated readme * prettier * Fix private cluster kubectl exit code bug (#252) * add private cluster exitCode check * add proper output * Added Integration Tests, Resolved Bugs With Annotations (#255) * First commit - made manifests for test deployments, made manifests for i tests for other deployment strategies * broke down blue/green * added latest tags to test manifests for new tags * remade tester * ready to test bgi * using all but first index of argv * careless error with dicts * added test to namespace * realized i was silencing error * indexing containers * keyerror * logging bc python errors are weird * expected still string * parsed args behaving weirdly * test seems to be working now, applying changes to other YAMLs now * blue/green ready to test * oops * oops * Added additional labels to check * hyphen * Added our annotations * lol * added our labels to services too * nonetype issue' * nonetype issue' * narrowing down parameter * fixed annotations issue with promote * adding debhug statement to figure out why services aren't getting annotations * this should fix annotations issue for service * not sure why this wasn't caught by intellisense * should be fixed with removing comma but adding logs in case * added linkerd install * verification * upgraded kubernetes version * removing crds * proxy option * Added smi extension * logging service * smi svcs also getting labeled now * matching ts type * not sure where stable service is going * remaining svc and deployment should match * keeping stable service and ts object * updated tests to reflect keeping ts object * no green svc after promote * duh * lol * canary work * canary test ready * logging for ing, filename for canary * changed ingress svc key and returning svc files from smi canary deployment * ts name * forgot about baseline in first deploy * * * * * smi canary should annotate, fixed cleanup * typescript issue plus percentage * forgot to type extra method * removed cleaned up objects from annotate list * logging because services aren't getting removed * moving to try/catch strategy of annotation since deletion can fail silently/with warnings * moved label to individual * removing canary service check after promote * pod ready for testing * set weights to 1000 * selectors * * * percentage * * * typing * mixed up pod and smi * fixed tests * prettier * forgot to remove canary * cleanup * Added oliver's feedback + more cleanup * ncc as dev dependency * npx * going back to global ncc install bc npm is being weird * prettier * removed unnecessary post step * new commit with all changes (#258) * Fixing Ubuntu Runner Issue (#259) * changed ubuntu runner * changed minikube action * Version formatting * nonedriveR * update kube version * installing conntrack' * updated other actions * update bg ingress api version * prettify * updated ingress backend for new api version * Added path type * prettify * Add skip tls flag (#260) * bump @actions/core (#262) * fixed files to file (#265) * Update README.md to v4 (#263) * Add node modules and compiled JavaScript from main Signed-off-by: Jaiveer Katariya Signed-off-by: dependabot[bot] Co-authored-by: nv35 <76777923+nv35@users.noreply.github.com> Co-authored-by: Vidya <59590642+Vidya2606@users.noreply.github.com> Co-authored-by: David Gamero Co-authored-by: Hariharan Subramanian <105889062+hsubramanianaks@users.noreply.github.com> Co-authored-by: Vidya Reddy Co-authored-by: Oliver King Co-authored-by: Marcus-Hines Co-authored-by: Jaiveer Katariya <35347859+jaiveerk@users.noreply.github.com> Co-authored-by: Jaiveer Katariya Co-authored-by: Jaiveer Katariya Co-authored-by: Alexander Bartsch Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kenta Nakase Co-authored-by: Asa Gayle --- README.md | 18 ++++---- lib/index.js | 59 ++++++++++++++++--------- package-lock.json | 14 +++--- package.json | 2 +- src/strategyHelpers/deploymentHelper.ts | 2 +- 5 files changed, 55 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index ee0bb17ba..bc1ff0653 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ Following are the key capabilities of this action: ### Basic deployment (without any deployment strategy) ```yaml -- uses: Azure/k8s-deploy@v3.1 +- uses: Azure/k8s-deploy@v4 with: namespace: 'myapp' manifests: | @@ -162,7 +162,7 @@ Following are the key capabilities of this action: ### Canary deployment without service mesh ```yaml -- uses: Azure/k8s-deploy@v3.1 +- uses: Azure/k8s-deploy@v4 with: namespace: 'myapp' images: 'contoso.azurecr.io/myapp:${{ event.run_id }}' @@ -181,7 +181,7 @@ Following are the key capabilities of this action: To promote/reject the canary created by the above snippet, the following YAML snippet could be used: ```yaml -- uses: Azure/k8s-deploy@v3.1 +- uses: Azure/k8s-deploy@v4 with: namespace: 'myapp' images: 'contoso.azurecr.io/myapp:${{ event.run_id }}' @@ -199,7 +199,7 @@ To promote/reject the canary created by the above snippet, the following YAML sn ### Canary deployment based on Service Mesh Interface ```yaml -- uses: Azure/k8s-deploy@v3.1 +- uses: Azure/k8s-deploy@v4 with: namespace: 'myapp' images: 'contoso.azurecr.io/myapp:${{ event.run_id }}' @@ -220,7 +220,7 @@ To promote/reject the canary created by the above snippet, the following YAML sn To promote/reject the canary created by the above snippet, the following YAML snippet could be used: ```yaml -- uses: Azure/k8s-deploy@v3.1 +- uses: Azure/k8s-deploy@v4 with: namespace: 'myapp' images: 'contoso.azurecr.io/myapp:${{ event.run_id }} ' @@ -239,7 +239,7 @@ To promote/reject the canary created by the above snippet, the following YAML sn ### Blue-Green deployment with different route methods ```yaml -- uses: Azure/k8s-deploy@v3.1 +- uses: Azure/k8s-deploy@v4 with: namespace: 'myapp' images: 'contoso.azurecr.io/myapp:${{ event.run_id }}' @@ -259,7 +259,7 @@ To promote/reject the canary created by the above snippet, the following YAML sn To promote/reject the green workload created by the above snippet, the following YAML snippet could be used: ```yaml -- uses: Azure/k8s-deploy@v3.1 +- uses: Azure/k8s-deploy@v4 with: namespace: 'myapp' images: 'contoso.azurecr.io/myapp:${{ event.run_id }}' @@ -316,7 +316,7 @@ jobs: container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} secret-name: demo-k8s-secret - - uses: Azure/k8s-deploy@v3.1 + - uses: Azure/k8s-deploy@v4 with: action: deploy manifests: | @@ -362,7 +362,7 @@ jobs: container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} secret-name: demo-k8s-secret - - uses: Azure/k8s-deploy@v3.1 + - uses: Azure/k8s-deploy@v4 with: action: deploy manifests: | diff --git a/lib/index.js b/lib/index.js index ce2f64316..0a5731525 100644 --- a/lib/index.js +++ b/lib/index.js @@ -140,7 +140,6 @@ const file_command_1 = __nccwpck_require__(8466); const utils_1 = __nccwpck_require__(7369); const os = __importStar(__nccwpck_require__(2037)); const path = __importStar(__nccwpck_require__(1017)); -const uuid_1 = __nccwpck_require__(487); const oidc_utils_1 = __nccwpck_require__(7557); /** * The code to exit an action @@ -170,20 +169,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. - if (name.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedVal.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -201,7 +189,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -241,7 +229,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -274,8 +265,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -404,7 +399,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -470,13 +469,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); +const uuid_1 = __nccwpck_require__(487); const utils_1 = __nccwpck_require__(7369); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -488,7 +488,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -22060,7 +22075,7 @@ function labelResources(files, kubectl, label) { const labelResults = []; for (const file of files) { try { - const labelResult = yield kubectl.labelFiles(files, labels); + const labelResult = yield kubectl.labelFiles(file, labels); labelResults.push(labelResult); } catch (e) { diff --git a/package-lock.json b/package-lock.json index 7f6431d18..77657281e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "license": "MIT", "dependencies": { - "@actions/core": "^1.9.1", + "@actions/core": "^1.10.0", "@actions/exec": "^1.0.0", "@actions/io": "^1.0.0", "@actions/tool-cache": "1.1.2", @@ -30,9 +30,9 @@ } }, "node_modules/@actions/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", - "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", + "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", "dependencies": { "@actions/http-client": "^2.0.1", "uuid": "^8.3.2" @@ -6529,9 +6529,9 @@ }, "dependencies": { "@actions/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", - "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", + "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", "requires": { "@actions/http-client": "^2.0.1", "uuid": "^8.3.2" diff --git a/package.json b/package.json index 88d3d6567..b35032bc1 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "format-check": "prettier --check ." }, "dependencies": { - "@actions/core": "^1.9.1", + "@actions/core": "^1.10.0", "@actions/exec": "^1.0.0", "@actions/io": "^1.0.0", "@actions/tool-cache": "1.1.2", diff --git a/src/strategyHelpers/deploymentHelper.ts b/src/strategyHelpers/deploymentHelper.ts index d4645d74e..bd1d7c029 100644 --- a/src/strategyHelpers/deploymentHelper.ts +++ b/src/strategyHelpers/deploymentHelper.ts @@ -258,7 +258,7 @@ async function labelResources( const labelResults = [] for (const file of files) { try { - const labelResult = await kubectl.labelFiles(files, labels) + const labelResult = await kubectl.labelFiles(file, labels) labelResults.push(labelResult) } catch (e) { core.warning(`failed to annotate resource: ${e}`)