36
36
required : true
37
37
type : string
38
38
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'
44
39
values-file-path :
45
- required : true
40
+ required : false
46
41
type : string
47
42
description : ' Values file path from helm chart directory'
48
43
history-max :
49
44
required : true
50
45
type : number
51
46
description : ' number of revisions stored in the revision history.'
52
- default : 7
53
47
namespace :
54
48
required : false
55
49
type : string
56
50
description : ' Boundary for Kubernetes resources'
57
51
rollback :
58
52
required : false
59
- type : string
53
+ type : boolean
60
54
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.'
61
69
secrets :
62
70
AWS_ACCESS_KEY_ID :
63
71
description : ' AWS Access Key ID'
74
82
AZURE_CREDENTIALS :
75
83
description : ' Azure Credentilas'
76
84
required : false
85
+ set-parameters :
86
+ required : false
87
+ description : ' Overriding the default values using --set flag'
77
88
jobs :
78
89
helm-action :
79
90
runs-on : ubuntu-latest
91
102
aws-session-token : ${{ secrets.AWS_SESSION_TOKEN }}
92
103
role-to-assume : ${{ secrets.BUILD_ROLE }}
93
104
aws-region : ${{ inputs.aws_region }}
94
- role-duration-seconds : 900
105
+ role-duration-seconds : ${{ inputs.role-duration-seconds }}
95
106
role-skip-session-tagging : true
96
107
97
108
- name : Install Azure CLI
@@ -105,32 +116,38 @@ jobs:
105
116
if [ "${{ inputs.provider }}" = "azure" ]; then
106
117
az aks get-credentials --resource-group ${{ inputs.resource-group }} --name ${{ inputs.azure-cluster-name }}
107
118
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 }}
109
120
fi
110
121
111
122
- name : helm lint
112
- if : ${{ inputs.rollback != 'rollback' }}
123
+ if : ${{ inputs.rollback != true && inputs.uninstall != true }}
113
124
run : |
114
- helm lint ${{ inputs.helm-chart-directory }}
125
+ helm lint ${{ inputs.helm-chart-directory }} -f ${{ inputs.values-file-path }}
115
126
116
127
- name : helm template
117
- if : ${{ inputs.rollback != 'rollback' }}
128
+ if : ${{ inputs.rollback != true && inputs.uninstall != true }}
118
129
run : |
119
- helm template ${{ inputs.helm-chart-directory }}
130
+ helm template ${{ inputs.helm-chart-directory }} -f ${{ inputs.values-file-path }}
120
131
121
132
- name : helm install and upgrade2
122
- if : ${{ inputs.rollback != 'rollback' }}
133
+ if : ${{ inputs.rollback != true && inputs.uninstall != true }}
123
134
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 }}
127
138
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 }}
130
141
fi
131
142
132
143
- 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 }}
134
151
run : |
135
- helm rollback ${{ inputs.release-name }} -n ${{ inputs.namespace }}
152
+ helm uninstall ${{ inputs.release-name }} -n ${{ inputs.namespace }}
136
153
...
0 commit comments