helm.yml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. name: Helm
  2. on:
  3. push:
  4. branches:
  5. - main
  6. - release-*
  7. paths:
  8. - 'deploy/charts/**'
  9. - 'deploy/crds/**'
  10. pull_request:
  11. paths:
  12. - 'deploy/charts/**'
  13. - 'deploy/crds/**'
  14. workflow_dispatch: {}
  15. permissions:
  16. contents: read
  17. jobs:
  18. lint-and-test:
  19. runs-on: ubuntu-latest
  20. steps:
  21. - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
  22. with:
  23. egress-policy: audit
  24. - name: Checkout
  25. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  26. with:
  27. fetch-depth: 0
  28. - name: Generate chart
  29. run: |
  30. make helm.generate
  31. - name: Set up Helm
  32. uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
  33. with:
  34. version: v3.14.2 # remember to also update for the second job (release)
  35. - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
  36. with:
  37. python-version: 3.12
  38. - name: Set up chart-testing
  39. uses: helm/chart-testing-action@0d28d3144d3a25ea2cc349d6e59901c4ff469b3b # v2.7.0
  40. - name: Run chart-testing (list-changed)
  41. id: list-changed
  42. run: |
  43. changed=$(ct list-changed --config=.github/ci/ct.yaml)
  44. if [[ -n "$changed" ]]; then
  45. echo "changed=true" >> $GITHUB_OUTPUT
  46. fi
  47. - name: Install chart unittest
  48. run: |
  49. helm env
  50. helm plugin install https://github.com/helm-unittest/helm-unittest
  51. - name: Run chart-testing (lint)
  52. run: ct lint --config=.github/ci/ct.yaml
  53. - name: Create kind cluster
  54. uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
  55. if: steps.list-changed.outputs.changed == 'true'
  56. - name: Run chart-testing (install)
  57. run: ct install --config=.github/ci/ct.yaml --charts deploy/charts/external-secrets
  58. if: steps.list-changed.outputs.changed == 'true'
  59. - name: Run unitests
  60. if: steps.list-changed.outputs.changed == 'true'
  61. run: make helm.test
  62. check-release:
  63. permissions:
  64. contents: read
  65. outputs:
  66. release_exists: ${{ steps.check_release.outputs.release_exists }}
  67. runs-on: ubuntu-latest
  68. steps:
  69. - name: Harden the runner (Audit all outbound calls)
  70. uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
  71. with:
  72. egress-policy: audit
  73. - name: Checkout
  74. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  75. with:
  76. fetch-depth: 0
  77. - name: Check if release already exists
  78. id: check_release
  79. run: |
  80. release_version=$(yq .version deploy/charts/external-secrets/Chart.yaml)
  81. release_status=$(curl --silent -w "%{http_code}" --output /dev/null "https://api.github.com/repos/external-secrets/external-secrets/releases/tags/helm-chart-${release_version}")
  82. if [ $release_status -eq 200 ]; then
  83. echo "Release already exists"
  84. echo "release_exists='true'">> $GITHUB_OUTPUT
  85. else
  86. echo "Release does not exist"
  87. echo "release_exists='false'" >> $GITHUB_OUTPUT
  88. fi
  89. release:
  90. needs:
  91. - check-release
  92. if: needs.check-release.outputs.release_exists == 'false' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-'))
  93. permissions:
  94. contents: write # for helm/chart-releaser-action to push chart release and create a release
  95. packages: write # to push OCI chart package to GitHub Registry
  96. id-token: write # gives the action the ability to mint the OIDC token necessary to request a Sigstore signing certificate
  97. attestations: write # this permission is necessary to persist the attestation
  98. runs-on: ubuntu-latest
  99. steps:
  100. - name: Harden the runner (Audit all outbound calls)
  101. uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
  102. with:
  103. egress-policy: audit
  104. - name: Checkout
  105. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  106. with:
  107. fetch-depth: 0
  108. - name: Configure Git
  109. run: |
  110. git config user.name "$GITHUB_ACTOR"
  111. git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
  112. - name: Set up Helm
  113. uses: azure/setup-helm@f382f75448129b3be48f8121b9857be18d815a82 # v3.4
  114. with:
  115. version: v3.4.2
  116. - name: Generate chart
  117. run: make helm.generate
  118. - name: Import GPG key
  119. run: |
  120. echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --dearmor --output keyring.gpg
  121. echo -n "${{ secrets.GPG_PASSPHRASE }}" > passphrase-file.txt
  122. - name: Run chart-releaser
  123. uses: helm/chart-releaser-action@cae68fefc6b5f367a0275617c9f83181ba54714f # v1.7.0
  124. env:
  125. CR_KEY: external-secrets <external-secrets@external-secrets.io>
  126. CR_KEYRING: keyring.gpg
  127. CR_PASSPHRASE_FILE: passphrase-file.txt
  128. CR_SIGN: true
  129. CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  130. CR_RELEASE_NAME_TEMPLATE: "helm-chart-{{ .Version }}"
  131. with:
  132. charts_dir: deploy/charts
  133. skip_existing: true
  134. charts_repo_url: https://charts.external-secrets.io
  135. - name: Set up Helm
  136. uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
  137. with:
  138. version: v3.14.2 # remember to also update for the first job (lint-and-test)
  139. - name: Login to GHCR
  140. uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
  141. with:
  142. registry: ghcr.io
  143. username: ${{ github.actor }}
  144. password: ${{ secrets.GITHUB_TOKEN }}
  145. - name: Install cosign
  146. uses: sigstore/cosign-installer@3454372f43399081ed03b604cb2d021dabca52bb # v3.8.2
  147. with:
  148. cosign-release: 'v2.4.1'
  149. - name: Push chart to GHCR
  150. id: push_chart
  151. run: |
  152. shopt -s nullglob
  153. for pkg in .cr-release-packages/*.tgz; do
  154. if [ -z "${pkg:-}" ]; then
  155. break
  156. fi
  157. chart_name=$(helm show chart "${pkg}" | yq .name)
  158. # helm push fails when registry path contains Uppercase letters
  159. chart_registry="ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts"
  160. helm_push_output=$(helm push "${pkg}" "oci://${chart_registry}" 2>&1)
  161. digest=$(echo "$helm_push_output" | grep -o 'sha256:[a-z0-9]*')
  162. echo "$helm_push_output"
  163. artifact_digest_uri="${chart_registry}/${chart_name}@${digest}"
  164. cosign sign --yes "$artifact_digest_uri"
  165. cosign verify "$artifact_digest_uri" \
  166. --certificate-identity-regexp "https://github.com/$GITHUB_REPOSITORY/*" \
  167. --certificate-oidc-issuer https://token.actions.githubusercontent.com
  168. echo "digest=${digest}" >> "$GITHUB_OUTPUT"
  169. echo "chart_name=${chart_name}" >> "$GITHUB_OUTPUT"
  170. echo "registry=${chart_registry}" >> "$GITHUB_OUTPUT"
  171. done
  172. - name: Generate provenance attestation and push to OCI registry
  173. uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd # v2.3.0
  174. with:
  175. push-to-registry: true
  176. subject-name: ${{ steps.push_chart.outputs.registry }}/${{ steps.push_chart.outputs.chart_name }}
  177. subject-digest: ${{ steps.push_chart.outputs.digest }}