Skip to content

Commit

Permalink
chore: add support for basic auth (#8)
Browse files Browse the repository at this point in the history
* chore: add variables

* chore: add support for basic auth

* fix: bash syntax

* fix: bash syntax

* fix: bash syntax

* fix: bash syntax

* fix: bash syntax

* choree: update pipeline variables

* choree: update pipeline variables

* fix: release not found

* chore: update values
  • Loading branch information
matiri132 authored Feb 8, 2022
1 parent e8d9915 commit f00beeb
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 10 deletions.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ Following inputs can be used as `step.with` keys
| `namespace` | String | Kubernetes namespace to use. |
| `values` | String | Comma separates list of value set for helms. e.x: key1=value1,key2=value2 |
| `name` | String | The name of the helm release |
| `chart-path` | String | The path to the chart. (defaults to `helm/`) |
| `chart-path` | String | The path to the chart. (defaults to `helm/`) (For local repo)|
| `chart-repository` | String | The URL of the chart repository. (For remote repo)|
| `chart-name` | String | Helm chart name inside the repository. (For remote repo)|
| `repo-username` | String | Username for repository basic auth|
| `repo-password` | String | Password for repository basic auth|


## Example usage
#### Local repository

```yaml
uses: craftech-io/eks-helm-deploy-action@v1
Expand All @@ -36,4 +41,40 @@ with:
namespace: dev
values: key1=value1,key2=value2
name: release_name
```
#### Remote repository
```yaml
uses: craftech-io/eks-helm-deploy-action@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS__KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
cluster-name: mycluster
config-files: .github/values/dev.yaml
chart-repository: https://chartmuseum.mgt.example.com
chart-name: example
namespace: dev
values: key1=value1,key2=value2
name: release_name
```
#### Remote repository w/basic auth
```yaml
uses: craftech-io/eks-helm-deploy-action@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS__KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
cluster-name: mycluster
config-files: .github/values/dev.yaml
chart-repository: https://chartmuseum.mgt.example.com
chart-name: example
repo-username: user
repo-password: aV3ryC0mpl3xP455w0rd
namespace: dev
values: key1=value1,key2=value2
name: release_name
```
18 changes: 17 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ inputs:
chart-repository:
description: 'The repository of the chart.'
required: false
chart-name:
description: 'Chart name in the repository'
required: false
timeout:
description: 'Timeout for the job.'
required: true
Expand All @@ -48,6 +51,15 @@ inputs:
description: 'Update chart dependencies'
required: false
default: "true"
repo-name:
description: 'Name of the repository'
required: false
repo-username:
description: 'Username to authenticate to the repository.'
required: false
repo-password:
description: 'Password to authenticate to repository.'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -64,4 +76,8 @@ runs:
DEPLOY_CHART_PATH: ${{ inputs.chart-path }}
TIMEOUT: ${{ inputs.timeout }}
UPDATE_DEPS: ${{ inputs.update-deps }}
HELM_REPOSITORY: ${{ inputs.chart-repository }}
HELM_REPOSITORY: ${{ inputs.chart-repository }}
HELM_CHART_NAME: ${{ inputs.chart-name }}
REPO_NAME: ${{ inputs.repo-name }}
REPO_USERNAME: ${{ inputs.repo-username }}
REPO_PASSWORD: ${{ inputs.repo-password }}
38 changes: 30 additions & 8 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,32 @@ fi

# Helm Deployment

if [ -n "$HELM_REPOSITORY" ]; then
HELM_CHART_NAME=${DEPLOY_CHART_PATH%/*}
DEPS_UPDATE_COMMAND="helm repo add ${HELM_CHART_NAME} ${HELM_REPOSITORY}"
####################
# Dependency Update
####################
# Verify local or remote repository
if [ -z ${HELM_CHART_NAME} ]; then
HELM_CHART_NAME=${DEPLOY_CHART_PATH%/*}
fi
if [ ! -z "$HELM_REPOSITORY" ]; then
#Verify basic auth
if [ ! -z ${REPO_USERNAME} ] && [ ! -z ${REPO_PASSWORD} ]; then
echo "Executing: helm repo add --username="${REPO_USERNAME}" --password="${REPO_PASSWORD}" ${HELM_CHART_NAME} ${HELM_REPOSITORY}"
helm repo add --username="${REPO_USERNAME}" --password="${REPO_PASSWORD}" ${HELM_CHART_NAME} ${HELM_REPOSITORY}
else
echo "Executing: helm repo add ${HELM_CHART_NAME} ${HELM_REPOSITORY}"
helm repo add ${HELM_CHART_NAME} ${HELM_REPOSITORY}
fi
else
DEPS_UPDATE_COMMAND="helm dependency update ${DEPLOY_CHART_PATH}"
echo "Executing: helm dependency update ${DEPLOY_CHART_PATH}"
helm dependency update ${DEPLOY_CHART_PATH}
fi

UPGRADE_COMMAND="helm upgrade --timeout ${TIMEOUT}"
####################
# Helm upgrade
####################

UPGRADE_COMMAND="helm upgrade -i --timeout ${TIMEOUT}"
for config_file in ${DEPLOY_CONFIG_FILES//,/ }
do
UPGRADE_COMMAND="${UPGRADE_COMMAND} -f ${config_file}"
Expand All @@ -32,8 +50,12 @@ fi
if [ -n "$DEPLOY_VALUES" ]; then
UPGRADE_COMMAND="${UPGRADE_COMMAND} --set ${DEPLOY_VALUES}"
fi
UPGRADE_COMMAND="${UPGRADE_COMMAND} ${DEPLOY_NAME} ${DEPLOY_CHART_PATH}"
echo "Executing: ${DEPS_UPDATE_COMMAND}"
${DEPS_UPDATE_COMMAND}

if [ -z "$HELM_REPOSITORY" ]; then
UPGRADE_COMMAND="${UPGRADE_COMMAND} ${DEPLOY_NAME} ${DEPLOY_CHART_PATH}"
else
UPGRADE_COMMAND="${UPGRADE_COMMAND} ${DEPLOY_NAME} ${HELM_CHART_NAME}/${HELM_CHART_NAME}"
fi

echo "Executing: ${UPGRADE_COMMAND}"
${UPGRADE_COMMAND}

0 comments on commit f00beeb

Please sign in to comment.