|
| 1 | +name: HELM |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + aws-region: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + description: 'AWS EKS cluster region' |
| 10 | + eks-cluster-name: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + description: 'EKS cluster name' |
| 14 | + namespace: |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + description: 'Boundary for Kubernetes resources' |
| 18 | + helm-chart-directory: |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + description: 'Kubernetes deployment configurations files' |
| 22 | + release-name: |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + description: 'Unique ID for installed chart' |
| 26 | + rollback: |
| 27 | + required: false |
| 28 | + type: string |
| 29 | + description: 'Environment name for rollback' |
| 30 | + timeout: |
| 31 | + required: true |
| 32 | + type: string |
| 33 | + description: 'Timeout for helm install step in seconds' |
| 34 | + set-parameters: |
| 35 | + required: false |
| 36 | + type: string |
| 37 | + description: 'Overriding the default values' |
| 38 | + values-file-path: |
| 39 | + required: true |
| 40 | + type: string |
| 41 | + description: 'Values file path from helm chart directory' |
| 42 | + history-max: |
| 43 | + required: true |
| 44 | + type: number |
| 45 | + description: 'number of revisions stored in the revision history.' |
| 46 | + secrets: |
| 47 | + aws-access-key-id: |
| 48 | + description: 'AWS Access Key ID' |
| 49 | + required: true |
| 50 | + aws-secret-access-key: |
| 51 | + description: 'AWS Secret Access Key' |
| 52 | + required: true |
| 53 | +jobs: |
| 54 | + helm-action: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout git repo |
| 59 | + uses: actions/checkout@v3 |
| 60 | + |
| 61 | + - name: Configure AWS credentials |
| 62 | + uses: aws-actions/configure-aws-credentials@v1 |
| 63 | + with: |
| 64 | + aws-access-key-id: ${{ secrets.aws-access-key-id }} |
| 65 | + aws-secret-access-key: ${{ secrets.aws-secret-access-key }} |
| 66 | + aws-region: ${{ inputs.aws-region }} |
| 67 | + |
| 68 | + - name: Update Kubeconfig |
| 69 | + run: | |
| 70 | + aws eks --region ${{ inputs.aws-region }} update-kubeconfig --name ${{ inputs.eks-cluster-name }} |
| 71 | + |
| 72 | + - name: helm lint |
| 73 | + if: ${{ inputs.rollback != 'rollback' }} |
| 74 | + run: | |
| 75 | + helm lint ${{ inputs.helm-chart-directory }} |
| 76 | + |
| 77 | + - name: helm template |
| 78 | + if: ${{ inputs.rollback != 'rollback' }} |
| 79 | + run: | |
| 80 | + helm template ${{ inputs.helm-chart-directory }} |
| 81 | + |
| 82 | + - name: helm install and upgrade2 |
| 83 | + if: ${{ inputs.rollback != 'rollback' }} |
| 84 | + run: | |
| 85 | + if [ -n "${{ inputs.set-parameters }}" ]; then |
| 86 | + helm upgrade --install --atomic --create-namespace --wait --history-max ${{ inputs.history-max }} --debug \ |
| 87 | + ${{ inputs.release-name }} ${{ inputs.helm-chart-directory }} ${{ inputs.set-parameters }} -f ${{ inputs.values-file-path }} --namespace=${{ inputs.namespace }} --timeout ${{ inputs.timeout }} |
| 88 | + else |
| 89 | + helm upgrade --install --atomic --create-namespace --wait --history-max ${{ inputs.history-max }} --debug \ |
| 90 | + ${{ inputs.release-name }} ${{ inputs.helm-chart-directory }} -f ${{ inputs.values-file-path }} --namespace=${{ inputs.namespace }} --timeout ${{ inputs.timeout }} |
| 91 | + fi |
| 92 | + |
| 93 | + - name: Rollback Helm Release |
| 94 | + if: ${{ inputs.rollback == 'rollback' }} |
| 95 | + run: | |
| 96 | + helm rollback ${{ inputs.release-name }} -n ${{ inputs.namespace }} |
0 commit comments