3636 required : true
3737 type : string
3838 description : ' Timeout for helm install step in seconds'
39- default : ' 120s'
40- set-parameters :
41- required : false
42- type : string
43- description : ' Overriding the default values'
4439 values-file-path :
45- required : true
40+ required : false
4641 type : string
4742 description : ' Values file path from helm chart directory'
4843 history-max :
4944 required : true
5045 type : number
5146 description : ' number of revisions stored in the revision history.'
52- default : 7
5347 namespace :
5448 required : false
5549 type : string
5650 description : ' Boundary for Kubernetes resources'
5751 rollback :
5852 required : false
59- type : string
53+ type : boolean
6054 description : ' Environment name for rollback'
55+ revision :
56+ required : false
57+ type : number
58+ description : ' If this argument is omitted or set to 0, it will roll back to the previous release.'
59+ uninstall :
60+ required : false
61+ type : boolean
62+ default : false
63+ description : ' Set true to uninstall helmchart'
64+ role-duration-seconds :
65+ required : false
66+ type : number
67+ default : 900
68+ description : ' The assumed role duration in seconds, if assuming a role. Defaults to 1 hour.'
6169 secrets :
6270 AWS_ACCESS_KEY_ID :
6371 description : ' AWS Access Key ID'
7482 AZURE_CREDENTIALS :
7583 description : ' Azure Credentilas'
7684 required : false
85+ set-parameters :
86+ required : false
87+ description : ' Overriding the default values using --set flag'
7788jobs :
7889 helm-action :
7990 runs-on : ubuntu-latest
91102 aws-session-token : ${{ secrets.AWS_SESSION_TOKEN }}
92103 role-to-assume : ${{ secrets.BUILD_ROLE }}
93104 aws-region : ${{ inputs.aws_region }}
94- role-duration-seconds : 900
105+ role-duration-seconds : ${{ inputs.role-duration-seconds }}
95106 role-skip-session-tagging : true
96107
97108 - name : Install Azure CLI
@@ -105,32 +116,38 @@ jobs:
105116 if [ "${{ inputs.provider }}" = "azure" ]; then
106117 az aks get-credentials --resource-group ${{ inputs.resource-group }} --name ${{ inputs.azure-cluster-name }}
107118 else
108- aws eks --region ${{ inputs.aws-region }} update-kubeconfig --name ${{ inputs.eks-cluster-name }}
119+ aws eks update-kubeconfig --name ${{ inputs.eks-cluster-name }} --region ${{ inputs.aws_region }}
109120 fi
110121
111122 - name : helm lint
112- if : ${{ inputs.rollback != 'rollback' }}
123+ if : ${{ inputs.rollback != true && inputs.uninstall != true }}
113124 run : |
114- helm lint ${{ inputs.helm-chart-directory }}
125+ helm lint ${{ inputs.helm-chart-directory }} -f ${{ inputs.values-file-path }}
115126
116127 - name : helm template
117- if : ${{ inputs.rollback != 'rollback' }}
128+ if : ${{ inputs.rollback != true && inputs.uninstall != true }}
118129 run : |
119- helm template ${{ inputs.helm-chart-directory }}
130+ helm template ${{ inputs.helm-chart-directory }} -f ${{ inputs.values-file-path }}
120131
121132 - name : helm install and upgrade2
122- if : ${{ inputs.rollback != 'rollback' }}
133+ if : ${{ inputs.rollback != true && inputs.uninstall != true }}
123134 run : |
124- if [ -n "${{ inputs .set-parameters }}" ]; then
125- helm upgrade --install --atomic --create-namespace --wait --history-max ${{ inputs.history-max }} --debug \
126- ${{ inputs.release-name }} ${{ inputs.helm-chart-directory }} ${{ inputs.set-parameters }} -f ${{ inputs.values-file-path }} --namespace=${{ inputs.namespace }} --timeout ${{ inputs.timeout }}
135+ if [ -n "${{ secrets .set-parameters }}" ]; then
136+ helm upgrade --install ${{ inputs.release-name }} ${{ inputs.helm-chart-directory }} -f ${{ inputs.values-file-path }} --namespace= ${{ inputs.namespace }} --create-namespace ${{ secrets.set-parameters }} \
137+ --history-max ${{ inputs.history-max }} --atomic --wait --debug --timeout ${{ inputs.timeout }}
127138 else
128- helm upgrade --install --atomic --create-namespace --wait --history-max ${{ inputs.history-max }} --debug \
129- ${{ inputs.release-name }} ${{ inputs.helm-chart-directory }} -f ${{ inputs.values-file-path }} --namespace=${{ inputs.namespace }} --timeout ${{ inputs.timeout }}
139+ helm upgrade --install ${{ inputs.release-name }} ${{ inputs.helm-chart-directory }} -f ${{ inputs.values-file-path }} --namespace= ${{ inputs.namespace }} --create-namespace \
140+ --history-max ${{ inputs.history-max }} --atomic --wait --debug --timeout ${{ inputs.timeout }}
130141 fi
131142
132143 - name : Rollback Helm Release
133- if : ${{ inputs.rollback == 'rollback' }}
144+ if : ${{ inputs.rollback == true && inputs.uninstall != true }}
145+ run : |
146+ export HISTORY_COUNT=$(helm history ${{ inputs.release-name }} -n ${{ inputs.namespace }} | head -2 | tail -1 | awk '{print $1}')
147+ helm rollback ${{ inputs.release-name }} -n ${{ inputs.namespace }} ${{ inputs.revision }} --debug || ( echo "Valid revision values can be greater than or equal to $HISTORY_COUNT" && exit 1 )
148+
149+ - name : Uninstall Helm Release
150+ if : ${{ inputs.uninstall == true }}
134151 run : |
135- helm rollback ${{ inputs.release-name }} -n ${{ inputs.namespace }}
152+ helm uninstall ${{ inputs.release-name }} -n ${{ inputs.namespace }}
136153 ...
0 commit comments