Skip to content

Commit

Permalink
feat: add environment variable for push helm package
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed Oct 6, 2023
1 parent c23bfbc commit 90eb9b7
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@

[![License](https://img.shields.io/github/license/1000kit/nx-plugins?style=for-the-badge&logo=apache)](https://www.apache.org/licenses/LICENSE-2.0)
[![Release version](https://img.shields.io/npm/v/%401000kit%2Fnx-helm-plugin?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@1000kit/nx-helm-plugin)


## Configuration

### nx-helm-plugin

To push helm package to OCI registry, you need to update the options.push property of your project target or use the INPUT_TKIT_HELM_PUSH environment variable.
46 changes: 44 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {},
"private": true,
"dependencies": {
"@nx-tools/core": "^5.0.3",
"@nx/devkit": "16.9.1",
"@nx/plugin": "^16.9.1",
"@swc/helpers": "~0.5.2",
Expand Down
1 change: 1 addition & 0 deletions plugins/nx-helm-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"name": "Andrej Petras"
},
"dependencies": {
"@nx-tools/core": "^5.0.3",
"@nx/devkit": "16.9.1",
"lodash.merge": "^4.6.2",
"tslib": "^2.3.0",
Expand Down
8 changes: 6 additions & 2 deletions plugins/nx-helm-plugin/src/executors/build/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { exec } from 'child_process';
import * as fs from 'fs';
import { parse, stringify } from 'yaml';
import merge from 'lodash.merge';
import { getBooleanInput } from '@nx-tools/core';

export default async function runExecutor(options: BuildExecutorSchema, context: ExecutorContext) {

Expand All @@ -18,6 +19,9 @@ export default async function runExecutor(options: BuildExecutorSchema, context:
const chartName = options.chartName || context.projectName;
const helmDir = projSourceDir + '/' + options.dir;

const prefix = 'tkit_helm'
const push = getBooleanInput('push', { prefix, fallback: `${options.push}` || 'false' });

console.info('%s helm directory: %s', _prefix, helmDir)


Expand All @@ -35,8 +39,8 @@ export default async function runExecutor(options: BuildExecutorSchema, context:
await cmd(_prefix, `helm package ${context.cwd}/${helmDir} --version ${options.version}`);

const packageFile = context.cwd + '/' + chartName + '-' + options.version + ".tgz";
if (options.push) {
await cmd(_prefix, `helm push ${packageFile} ${options.registry}`);
if (push) {
await cmd(_prefix, `helm push ${packageFile} ${options.registry}`);
} else {
console.info('%s skip push release version of the helm chart file %s', _prefix, packageFile);
}
Expand Down

0 comments on commit 90eb9b7

Please sign in to comment.