|
| 1 | +name: Publish helm chart |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - main # assume that the branch name may change in future |
| 8 | + paths: |
| 9 | + - 'charts/**' |
| 10 | + - '.github/**' |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +env: |
| 14 | + KUBE_SCORE_VERSION: 1.10.0 |
| 15 | + HELM_VERSION: v3.4.1 |
| 16 | + |
| 17 | +jobs: |
| 18 | + lint-chart: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Set up Helm |
| 27 | + uses: azure/setup-helm@v1 |
| 28 | + with: |
| 29 | + version: ${{ env.HELM_VERSION }} |
| 30 | + |
| 31 | + - name: Set up kube-score |
| 32 | + run: | |
| 33 | + wget https://github.com/zegl/kube-score/releases/download/v${{ env.KUBE_SCORE_VERSION }}/kube-score_${{ env.KUBE_SCORE_VERSION }}_linux_amd64 -O kube-score |
| 34 | + chmod 755 kube-score |
| 35 | +
|
| 36 | + - name: Kube-score generated manifests |
| 37 | + run: helm template --values charts/.ci/values-kube-score.yaml charts/* | ./kube-score score - |
| 38 | + --ignore-test pod-networkpolicy |
| 39 | + --ignore-test deployment-has-poddisruptionbudget |
| 40 | + --ignore-test deployment-has-host-podantiaffinity |
| 41 | + --ignore-test container-security-context |
| 42 | + --ignore-test pod-probes |
| 43 | + --ignore-test container-image-tag |
| 44 | + --enable-optional-test container-security-context-privileged |
| 45 | + --enable-optional-test container-security-context-readonlyrootfilesystem |
| 46 | + |
| 47 | + # python is a requirement for the chart-testing action below (supports yamllint among other tests) |
| 48 | + - uses: actions/setup-python@v2 |
| 49 | + with: |
| 50 | + python-version: 3.7 |
| 51 | + |
| 52 | + - name: Set up chart-testing |
| 53 | + uses: helm/chart-testing-action@v2.0.1 |
| 54 | + |
| 55 | + - name: Run chart-testing (list-changed) |
| 56 | + id: list-changed |
| 57 | + run: | |
| 58 | + changed=$(ct list-changed --config charts/.ci/ct-config.yaml) |
| 59 | + if [[ -n "$changed" ]]; then |
| 60 | + echo "::set-output name=changed::true" |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Run chart-testing (lint) |
| 64 | + run: ct lint --config charts/.ci/ct-config.yaml |
| 65 | + |
| 66 | + - name: Create kind cluster |
| 67 | + uses: helm/kind-action@v1.0.0 |
| 68 | + if: steps.list-changed.outputs.changed == 'true' |
| 69 | + |
| 70 | + - name: Run chart-testing (install) |
| 71 | + run: ct install --config charts/.ci/ct-config.yaml |
| 72 | + |
| 73 | + publish-chart: |
| 74 | + |
| 75 | + runs-on: ubuntu-latest |
| 76 | + needs: lint-chart |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout |
| 80 | + uses: actions/checkout@v2 |
| 81 | + with: |
| 82 | + fetch-depth: 0 |
| 83 | + |
| 84 | + - name: Configure Git |
| 85 | + run: | |
| 86 | + git config user.name "$GITHUB_ACTOR" |
| 87 | + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" |
| 88 | +
|
| 89 | + - name: Install Helm |
| 90 | + uses: azure/setup-helm@v1 |
| 91 | + with: |
| 92 | + version: ${{ env.HELM_VERSION }} |
| 93 | + |
| 94 | + # We need cert-manager already installed in the cluster because we assume the CRDs exist |
| 95 | + - name: Install cert-manager |
| 96 | + run: helm install cert-manager jetstack/cert-manager --set installCRDs=true --wait |
| 97 | + |
| 98 | + - name: Run chart-releaser |
| 99 | + uses: helm/chart-releaser-action@v1.1.0 |
| 100 | + env: |
| 101 | + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 102 | + |
0 commit comments