From 391e0e49afa5c4cbbcee6a7a0fcb059f36f2a94a Mon Sep 17 00:00:00 2001 From: Rob Coward Date: Tue, 2 Jul 2024 12:01:25 +0100 Subject: [PATCH 1/2] Initial commit with a test chart --- .github/workflows/lint-test.yaml | 45 ++++++++++++++++++++++++++++++++ .github/workflows/release.yaml | 27 +++++++++++++++++++ charts/test/Chart.yaml | 8 ++++++ charts/test/templates/test.yaml | 7 +++++ charts/test/values.yaml | 1 + 5 files changed, 88 insertions(+) create mode 100644 .github/workflows/lint-test.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 charts/test/Chart.yaml create mode 100644 charts/test/templates/test.yaml create mode 100644 charts/test/values.yaml diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml new file mode 100644 index 0000000..04bd6d9 --- /dev/null +++ b/.github/workflows/lint-test.yaml @@ -0,0 +1,45 @@ +name: Lint and Test Charts + +on: pull_request + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v4.2.0 + with: + version: v3.14.4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.7.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 --target-branch ${{ github.event.repository.default_branch }} + + - name: Create kind cluster + if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.10.0 + + - name: Run chart-testing (install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --target-branch ${{ github.event.repository.default_branch }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..e784b56 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,27 @@ +name: Release Charts + +on: + push: + branches: + - main + +jobs: + release: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/charts/test/Chart.yaml b/charts/test/Chart.yaml new file mode 100644 index 0000000..a4369a5 --- /dev/null +++ b/charts/test/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: test +description: Test Chart +maintainers: + - name: devops-consultants +type: application +version: 0.0.1 +appVersion: v0.0.1 diff --git a/charts/test/templates/test.yaml b/charts/test/templates/test.yaml new file mode 100644 index 0000000..4bfbd1c --- /dev/null +++ b/charts/test/templates/test.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: null + name: test +data: + message: "{{ .Values.testString }}" diff --git a/charts/test/values.yaml b/charts/test/values.yaml new file mode 100644 index 0000000..fc6efdc --- /dev/null +++ b/charts/test/values.yaml @@ -0,0 +1 @@ +testString: "Hello, World!" From 7a472f715ece6e8a7532360ea6be76ba7b231d8e Mon Sep 17 00:00:00 2001 From: Rob Coward Date: Tue, 2 Jul 2024 12:04:21 +0100 Subject: [PATCH 2/2] updated chart-testing-action version --- .github/workflows/lint-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index 04bd6d9..d40061d 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -22,7 +22,7 @@ jobs: check-latest: true - name: Set up chart-testing - uses: helm/chart-testing-action@v2.7.0 + uses: helm/chart-testing-action@v2.6.1 - name: Run chart-testing (list-changed) id: list-changed