helm.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. name: Helm
  2. on:
  3. push:
  4. branches:
  5. - main
  6. pull_request:
  7. workflow_dispatch: {}
  8. permissions:
  9. contents: read
  10. jobs:
  11. lint-and-test:
  12. runs-on: ubuntu-latest
  13. permissions:
  14. contents: read
  15. steps:
  16. - uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
  17. with:
  18. egress-policy: audit
  19. - name: Checkout
  20. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  21. with:
  22. fetch-depth: 0
  23. - name: Generate chart
  24. run: |
  25. make helm.generate
  26. - name: Set up Helm
  27. uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
  28. with:
  29. version: v3.14.2 # remember to also update for the second job (release)
  30. - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
  31. with:
  32. python-version: 3.12
  33. - name: Set up chart-testing
  34. uses: helm/chart-testing-action@6ec842c01de15ebb84c8627d2744a0c2f2755c9f # v2.8.0
  35. - name: Run chart-testing (list-changed)
  36. id: list-changed
  37. run: |
  38. changed=$(ct list-changed --config=.github/ci/ct.yaml)
  39. if [[ -n "$changed" ]]; then
  40. echo "changed=true" >> $GITHUB_OUTPUT
  41. fi
  42. - name: Run chart-testing (lint)
  43. run: ct lint --config=.github/ci/ct.yaml
  44. - name: Create kind cluster
  45. uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
  46. if: steps.list-changed.outputs.changed == 'true'
  47. - name: Run chart-testing (install)
  48. run: ct install --config=.github/ci/ct.yaml --charts deploy/charts/external-secrets
  49. if: steps.list-changed.outputs.changed == 'true'
  50. - name: Run unitests
  51. if: steps.list-changed.outputs.changed == 'true'
  52. run: make helm.test
  53. release:
  54. if: github.ref == 'refs/heads/main'
  55. permissions:
  56. contents: write # for helm/chart-releaser-action to push chart release and create a release
  57. packages: write # to push OCI chart package to GitHub Registry
  58. id-token: write # gives the action the ability to mint the OIDC token necessary to request a Sigstore signing certificate
  59. attestations: write # this permission is necessary to persist the attestation
  60. runs-on: ubuntu-latest
  61. steps:
  62. - name: Harden the runner (Audit all outbound calls)
  63. uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
  64. with:
  65. egress-policy: audit
  66. - name: Checkout
  67. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  68. with:
  69. fetch-depth: 0
  70. - name: Configure Git
  71. run: |
  72. git config user.name "$GITHUB_ACTOR"
  73. git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
  74. - name: Set up Helm
  75. uses: azure/setup-helm@f382f75448129b3be48f8121b9857be18d815a82 # v3.4
  76. with:
  77. version: v3.17.3
  78. - name: Generate chart
  79. run: make helm.generate
  80. - name: Import GPG key
  81. env:
  82. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  83. GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
  84. run: |
  85. gpg --dearmor --output keyring.gpg <(printf '%s' "$GPG_PRIVATE_KEY")
  86. chmod 600 keyring.gpg
  87. printf '%s' "$GPG_PASSPHRASE" > passphrase-file.txt
  88. chmod 600 passphrase-file.txt
  89. - name: Run chart-releaser
  90. uses: helm/chart-releaser-action@cae68fefc6b5f367a0275617c9f83181ba54714f # v1.7.0
  91. env:
  92. CR_KEY: external-secrets <external-secrets@external-secrets.io>
  93. CR_KEYRING: keyring.gpg
  94. CR_PASSPHRASE_FILE: passphrase-file.txt
  95. CR_SIGN: true
  96. CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  97. CR_RELEASE_NAME_TEMPLATE: "helm-chart-{{ .Version }}"
  98. with:
  99. charts_dir: deploy/charts
  100. skip_existing: true
  101. charts_repo_url: https://charts.external-secrets.io
  102. - name: Set up Helm
  103. uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
  104. with:
  105. version: v3.17.3 # remember to also update for the first job (lint-and-test)
  106. - name: Login to GHCR
  107. uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
  108. with:
  109. registry: ghcr.io
  110. username: ${{ github.actor }}
  111. password: ${{ secrets.GITHUB_TOKEN }}
  112. - name: Install cosign
  113. uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003 # v4.1.1
  114. with:
  115. cosign-release: 'v3.0.2'
  116. - name: Push chart to GHCR
  117. id: push_chart
  118. run: |
  119. shopt -s nullglob
  120. # helm push fails when registry path contains Uppercase letters
  121. chart_registry="ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts"
  122. for pkg in .cr-release-packages/*.tgz; do
  123. if [ -z "${pkg:-}" ]; then
  124. break
  125. fi
  126. chart_name=$(helm show chart "${pkg}" | yq .name)
  127. chart_version=$(helm show chart "${pkg}" | yq .version)
  128. if helm show chart oci://${chart_registry}/${chart_name} --version ${chart_version} > /dev/null 2>&1; then
  129. echo "Chart oci://${chart_name}:${chart_version} already exists in repository - skipping..."
  130. echo "push_status=skipped" >> "$GITHUB_OUTPUT"
  131. continue
  132. fi
  133. helm_push_output=$(helm push "${pkg}" "oci://${chart_registry}" 2>&1)
  134. digest=$(echo "$helm_push_output" | grep -o 'sha256:[a-z0-9]*')
  135. echo "$helm_push_output"
  136. artifact_digest_uri="${chart_registry}/${chart_name}@${digest}"
  137. cosign sign --yes --new-bundle-format=false --use-signing-config=false "$artifact_digest_uri"
  138. cosign verify --new-bundle-format=false "$artifact_digest_uri" \
  139. --certificate-identity-regexp "https://github.com/$GITHUB_REPOSITORY/.*" \
  140. --certificate-oidc-issuer https://token.actions.githubusercontent.com
  141. echo "digest=${digest}" >> "$GITHUB_OUTPUT"
  142. echo "push_status=pushed" >> "$GITHUB_OUTPUT"
  143. echo "chart_name=${chart_name}" >> "$GITHUB_OUTPUT"
  144. echo "registry=${chart_registry}" >> "$GITHUB_OUTPUT"
  145. done
  146. - name: Generate provenance attestation and push to OCI registry
  147. if: steps.push_chart.outputs.push_status == 'pushed'
  148. uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
  149. with:
  150. push-to-registry: true
  151. subject-name: ${{ steps.push_chart.outputs.registry }}/${{ steps.push_chart.outputs.chart_name }}
  152. subject-digest: ${{ steps.push_chart.outputs.digest }}