Skip to content

Commit

Permalink
v3 new release (#182)
Browse files Browse the repository at this point in the history
* Make pulling of images switchable (#178)

* Make namespace annotation switchable (#177)

* Bump tmpl from 1.0.4 to 1.0.5 (#152)

Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump ansi-regex from 5.0.0 to 5.0.1 (#166)

Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](chalk/ansi-regex@v5.0.0...v5.0.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump minimist from 1.2.5 to 1.2.6 (#175)

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add directory functionality (#181)

* Add node modules and compiled JavaScript from main

Co-authored-by: Jan Röhrich <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jaiveer Katariya <[email protected]>
Co-authored-by: Oliver King <[email protected]>
  • Loading branch information
5 people authored Apr 12, 2022
1 parent 08d466b commit e3c97bf
Show file tree
Hide file tree
Showing 32 changed files with 17,339 additions and 17,059 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/run-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Building latest changes
- name: Install dependencies
run: |
rm -rf node_modules/
npm install
npm run build
- name: Install ncc
run: npm i -g @vercel/ncc
- name: Build
run: ncc build src/run.ts -o lib

- name: Set name of ns
run: echo "::set-output name=name::$(echo `date +%Y%m%d%H%M%S`)"
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Following are the key capabilities of this action:
<tr>
<td>imagepullsecrets </br></br>(Optional)</td>
<td>Multiline input where each line contains the name of a docker-registry secret that has already been setup within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files</td>
</tr>
<tr>
<td>pull-images</br></br>(Optional)</td>
<td>Acceptable values: true/false</br>Default value: true</br>Switch whether to pull the images from the registry before deployment to find out Dockerfile's path in order to add it to the annotations</td>
</tr>
<tr>
<td>strategy </br></br>(Optional)</td>
Expand Down Expand Up @@ -90,6 +94,10 @@ Following are the key capabilities of this action:
<td>force </br></br>(Optional)</td>
<td>Deploy when a previous deployment already exists. If true then '--force' argument is added to the apply command. Using '--force' argument is not recommended in production.</td>
</tr>
<tr>
<td>annotate-namespace</br></br>(Optional)</td>
<td>Acceptable values: true/false</br>Default value: true</br>Switch whether to annotate the namespace resources object or not</td>
</tr>
</table>

## Usage Examples
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inputs:
imagepullsecrets:
description: "Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files"
required: false
pull-images:
description: "Switch whether to pull the images from the registry before deployment to find out Dockerfile's path in order to add it to the annotations"
required: false
default: true
strategy:
description: "Deployment strategy to be used. Allowed values are none, canary and blue-green"
required: false
Expand Down Expand Up @@ -51,6 +55,10 @@ inputs:
description: "Github token"
default: ${{ github.token }}
required: true
annotate-namespace:
description: "Annotate the target namespace"
required: false
default: true

branding:
color: "green"
Expand Down
72 changes: 60 additions & 12 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18192,6 +18192,7 @@ const promote_1 = __nccwpck_require__(3604);
const reject_1 = __nccwpck_require__(7530);
const action_1 = __nccwpck_require__(2868);
const deploymentStrategy_1 = __nccwpck_require__(7023);
const fileUtils_1 = __nccwpck_require__(7446);
function run() {
return __awaiter(this, void 0, void 0, function* () {
// verify kubeconfig is set
Expand All @@ -18205,22 +18206,23 @@ function run() {
.split(/[\n,;]+/) // split into each individual manifest
.map((manifest) => manifest.trim()) // remove surrounding whitespace
.filter((manifest) => manifest.length > 0); // remove any blanks
const fullManifestFilePaths = fileUtils_1.getFilesFromDirectories(manifestFilePaths);
// create kubectl
const kubectlPath = yield kubectl_1.getKubectlPath();
const namespace = core.getInput("namespace") || "default";
const kubectl = new kubectl_1.Kubectl(kubectlPath, namespace, true);
// run action
switch (action) {
case action_1.Action.DEPLOY: {
yield deploy_1.deploy(kubectl, manifestFilePaths, strategy);
yield deploy_1.deploy(kubectl, fullManifestFilePaths, strategy);
break;
}
case action_1.Action.PROMOTE: {
yield promote_1.promote(kubectl, manifestFilePaths, strategy);
yield promote_1.promote(kubectl, fullManifestFilePaths, strategy);
break;
}
case action_1.Action.REJECT: {
yield reject_1.reject(kubectl, manifestFilePaths, strategy);
yield reject_1.reject(kubectl, fullManifestFilePaths, strategy);
break;
}
default: {
Expand Down Expand Up @@ -19583,7 +19585,10 @@ function annotateResources(files, kubectl, resourceTypes, allPods, annotationKey
const namespace = core.getInput("namespace") || "default";
const lastSuccessSha = yield kubectlUtils_1.getLastSuccessfulRunSha(kubectl, namespace, annotationKey);
const annotationKeyValStr = `${annotationKey}=${workflowAnnotationUtils_1.getWorkflowAnnotations(lastSuccessSha, workflowFilePath, deploymentConfig)}`;
annotateResults.push(yield kubectl.annotate("namespace", namespace, annotationKeyValStr));
const annotateNamespace = !(core.getInput("annotate-namespace").toLowerCase() === "false");
if (annotateNamespace) {
annotateResults.push(yield kubectl.annotate("namespace", namespace, annotationKeyValStr));
}
annotateResults.push(yield kubectl.annotateFiles(files, annotationKeyValStr));
for (const resource of resourceTypes) {
if (resource.type.toLowerCase() !==
Expand Down Expand Up @@ -20082,13 +20087,16 @@ function getDeploymentConfig() {
}
const imageNames = core.getInput("images").split("\n") || [];
const imageDockerfilePathMap = {};
//Fetching from image label if available
for (const image of imageNames) {
try {
imageDockerfilePathMap[image] = yield getDockerfilePath(image);
}
catch (ex) {
core.warning(`Failed to get dockerfile path for image ${image.toString()}: ${ex} `);
const pullImages = !(core.getInput("pull-images").toLowerCase() === "false");
if (pullImages) {
//Fetching from image label if available
for (const image of imageNames) {
try {
imageDockerfilePathMap[image] = yield getDockerfilePath(image);
}
catch (ex) {
core.warning(`Failed to get dockerfile path for image ${image.toString()}: ${ex} `);
}
}
}
return Promise.resolve({
Expand Down Expand Up @@ -20135,7 +20143,7 @@ exports.checkDockerPath = checkDockerPath;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.writeManifestToFile = exports.writeObjectsToFile = exports.getTempDirectory = void 0;
exports.getFilesFromDirectories = exports.writeManifestToFile = exports.writeObjectsToFile = exports.getTempDirectory = void 0;
const fs = __nccwpck_require__(7147);
const path = __nccwpck_require__(1017);
const core = __nccwpck_require__(6024);
Expand Down Expand Up @@ -20186,6 +20194,46 @@ function getManifestFileName(kind, name) {
const tempDirectory = getTempDirectory();
return path.join(tempDirectory, path.basename(filePath));
}
function getFilesFromDirectories(filePaths) {
const fullPathSet = new Set();
filePaths.forEach((fileName => {
try {
if (fs.lstatSync(fileName).isDirectory()) {
recurisveManifestGetter(fileName).forEach((file) => { fullPathSet.add(file); });
}
else if (getFileExtension(fileName) === "yml" || getFileExtension(fileName) === "yaml") {
fullPathSet.add(fileName);
}
else {
core.debug(`Detected non-manifest file, ${fileName}, continuing... `);
}
}
catch (ex) {
throw Error(`Exception occurred while reading the file ${fileName}: ${ex}`);
}
}));
return Array.from(fullPathSet);
}
exports.getFilesFromDirectories = getFilesFromDirectories;
function recurisveManifestGetter(dirName) {
const toRet = [];
fs.readdirSync(dirName).forEach((fileName) => {
const fnwd = path.join(dirName, fileName);
if (fs.lstatSync(fnwd).isDirectory()) {
toRet.push(...recurisveManifestGetter(fnwd));
}
else if (getFileExtension(fileName) === "yml" || getFileExtension(fileName) === "yaml") {
toRet.push(path.join(dirName, fileName));
}
else {
core.debug(`Detected non-manifest file, ${fileName}, continuing... `);
}
});
return toRet;
}
function getFileExtension(fileName) {
return fileName.slice((fileName.lastIndexOf(".") - 1 >>> 0) + 2);
}


/***/ }),
Expand Down
Loading

0 comments on commit e3c97bf

Please sign in to comment.