set workflow for helm chart release #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Helm | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
changes: | |
permissions: | |
contents: read # for dorny/paths-filter to fetch a list of changed files | |
pull-requests: read # for dorny/paths-filter to read pull requests | |
runs-on: ubuntu-latest | |
outputs: | |
charts: ${{ steps.filter.outputs.charts }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.12.1 | |
- name: Set up chart-testing | |
uses: helm/chart-testing-action@v2.6.0 | |
- name: Run chart-testing (list-changed) | |
id: list-changed | |
run: | | |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }} ) | |
if [[ -n "$changed" ]]; then | |
echo "changed=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Run chart-testing (lint) | |
if: steps.list-changed.outputs.changed == 'true' | |
run: ct lint | |
- name: Create kind cluster | |
if: steps.list-changed.outputs.changed == 'true' | |
uses: helm/kind-action@v1.8.0 | |
- name: Run chart-testing (install) | |
if: steps.list-changed.outputs.changed == 'true' | |
run: ct install | |
- uses: dorny/paths-filter@v3.0.2 | |
id: filter | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
filters: | | |
charts: | |
- 'charts/metadata-injector/Chart.yaml' | |
- 'charts/metadata-injector/values.yaml' | |
chart: | |
name: Release Chart | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # needed to write releases | |
needs: | |
- changes | |
if: | | |
needs.changes.outputs.charts == 'true' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# Fetch entire history. Required for chart-releaser; see https://github.com/helm/chart-releaser-action/issues/13#issuecomment-602063896 | |
fetch-depth: 0 | |
- name: Setup | |
shell: bash | |
run: | | |
git config --global user.name "$GITHUB_ACTOR" | |
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
- name: Helm Chart Releaser | |
uses: helm/chart-releaser-action@v1.6.0 | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_RELEASE_NAME_TEMPLATE: "helm-chart-{{ .Version }}" | |
with: | |
charts_dir: charts |