Skip to content

Commit c60d2fa

Browse files
Added support for direct helm variables (#116)
* Added support for direct helm variables * Upgraded all upgradable dependencies * Updated action inputs for the direct helm variable prefix * Updated documentation for direct helm variable usage * Added support for multi-chart direct helm variables
1 parent 7f14f08 commit c60d2fa

File tree

5 files changed

+294
-349
lines changed

5 files changed

+294
-349
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,26 @@ For complex values, you'd want to not use the helm set variable from the command
108108
{ "key": "db.config", "value": "{ \"host\": \"db.example.com\", \"port\": 5432, \"username\": \"postgres\", \"password\": \"mysecretpassword\" }", "useFile": true, "chart": "auth-service" }
109109
```
110110

111+
## Direct Variables
112+
113+
There may be situations where you'd want to pass direct helm variables, and set their values. For those, we can use the Github variables with a special prefix. For example, if the prefix is `HELMVAR`, the variable name will need to start with `DEPLOYMENT_<prefix>[_<environment>]_HELMVAR_`. An example value can be:
114+
115+
```json
116+
{ "key": "ingress.tls[0].hosts[0]", "value": "my-svc.example.com", "chart": "common-config" }
117+
```
118+
119+
This will be passed as `--set ingress.tls[0].hosts[0]=my-svc.example.com` in the Helm command during deployment.
120+
121+
## Global Direct variables
122+
123+
To support situations where the same direct variable needs to be passed to multiple (all) charts, the chart key is optional. This is only the case for direct helm variables, as opposed to configmaps and secrets, which might create confusion if the keys are the same across multiple configmaps and secrets. For direct variables on the other hand, if the chart key is not provided, the variable will be passed to all Helm charts during deployment.
124+
125+
For example:
126+
127+
```json
128+
{ "key": "baseSubdomain", "value": "prod-us-east1.example.com" }
129+
```
130+
111131
## Example Action
112132

113133
The following example action will deploy the `auth-service` Helm chart.

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ inputs:
1414
description: "The Helm Deployment name that is to be deployed. Needed if the chart name and the deployment name need to be different"
1515
githubSecretVariablePrefix:
1616
description: "The Github Secret/Variable Prefix to be parsed for deployment"
17+
directVariablePrefix:
18+
description: "The Github Variable Prefix to be parsed for deployment as a direct helm variable. This will be used to infer direct variables for all the variables that have the key `DEPLOYMENT_<prefix>[_<environment>]_<directVariablePrefix>_<githubKeyName>`. The default value is `HELMVAR`."
19+
default: "HELMVAR"
1720
deploymentEnvironment:
1821
description: "The name of the Runtime environment. E.g. DEV, TEST, STAGING, UAT, PROD etc. Needs to match the context name in the Kube Config. Will default to the `current-context` in the Kube Config file for deployment. If provided, will be used in conjunction with the Github Secret/Variable Prefix. Only secrets or variables prefixed with `DEPLOYMENT_<prefix>[_<environment>]_<githubKeyName>` will be used"
1922
namespace:
@@ -83,6 +86,7 @@ runs:
8386
GITHUB_VARIABLES: ${{ inputs.variables }}
8487
ENVIRONMENT_VARIABLES: ${{ inputs.environmentVariables }}
8588
GITHUB_SECRET_VARIABLE_PREFIX: ${{ inputs.githubSecretVariablePrefix }}
89+
DIRECT_VARIABLE_PREFIX: ${{ inputs.directVariablePrefix }}
8690
DEPLOYMENT_ENVIRONMENT: ${{ inputs.deploymentEnvironment }}
8791
TAG: ${{ inputs.tag }}
8892
HELM_CONFIG_MAP_VARIABLE_NAME: ${{ inputs.helmConfigMapVariableName }}

0 commit comments

Comments
 (0)