diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a9ae379c..94023705 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,6 +10,8 @@ env: # Default minimum version of Go to support. DEFAULT_GO_VERSION: 1.19 REGISTRY: ghcr.io + GITHUB_PAGES_BRANCH: gh_pages + defaults: run: shell: bash @@ -42,35 +44,20 @@ jobs: runs-on: ubuntu-latest if: needs.release-please.outputs.releases_created == 'true' steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup go - uses: actions/setup-go@v4 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - - name: Configure Git - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - - name: Generate helm charts - run: IMG=ghcr.io/k8sgpt-ai/k8sgpt-operator:${{ needs.release-please.outputs.release_tag_name }} make helm-package - - - name: Commit files - run: | - git add charts/ - git add index.yaml - git commit -s -m "chore: released charts ${{ needs.release-please.outputs.release_tag_name }}" - - - name: Push changes - uses: ad-m/github-push-action@master + - uses: actions/checkout@v2 + - name: Publish Helm chart + uses: stefanprodan/helm-gh-pages@master with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ env.GITHUB_PAGES_BRANCH }} + token: ${{ secrets.K8SGPT_BOT_SECRET }} + charts_dir: chart + charts_url: https://charts.k8sgpt.ai + owner: k8sgpt-ai + repository: charts + branch: main + index_dir: ./ + target_dir: charts + commit_username: k8sgpt-ai-bot + commit_email: bot@noreply.k8sgpt.ai build-container: if: needs.release-please.outputs.releases_created == 'true' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 207a2e99..0ab81907 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,9 +1,6 @@ name: Run tests on: - push: - branches: - - main pull_request: branches: - main @@ -24,4 +21,46 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: Test - run: go test -v ./... \ No newline at end of file + run: go test -v ./... + + test-chart: + name: Test Helm Chart + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 + with: + fetch-depth: 0 + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: v3.11.2 + + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.4.0 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --chart-dirs chart --target-branch ${{ github.event.repository.default_branch }}) + echo $changed + echo "Hallo" + 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 --validate-maintainers=false --chart-dirs chart --target-branch ${{ github.event.repository.default_branch }} + + - name: Create kind cluster + if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.4.0 + + - name: Run chart-testing (install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --chart-dirs chart --target-branch ${{ github.event.repository.default_branch }} \ No newline at end of file diff --git a/Makefile b/Makefile index 98c738eb..d74e21b5 100644 --- a/Makefile +++ b/Makefile @@ -142,10 +142,10 @@ helm-build: helm helmify manifests kustomize $(KUSTOMIZE) build config/default | $(HELMIFY) helm-package: generate manifests - $(HELM) package --version $(CHART_VERSION) chart/ + $(HELM) package --version $(CHART_VERSION) chart/operator/ mkdir -p charts && mv k8sgpt-operator-*.tgz charts $(HELM) repo index --url https://charts.k8sgpt.ai/charts charts - mv charts/index.yaml index.yaml + mv charts/operator/index.yaml index.yaml ##@ Build Dependencies diff --git a/chart/.helmignore b/chart/operator/.helmignore similarity index 100% rename from chart/.helmignore rename to chart/operator/.helmignore diff --git a/chart/Chart.yaml b/chart/operator/Chart.yaml similarity index 87% rename from chart/Chart.yaml rename to chart/operator/Chart.yaml index 2985ebac..ded800a9 100644 --- a/chart/Chart.yaml +++ b/chart/operator/Chart.yaml @@ -1,6 +1,11 @@ apiVersion: v2 name: k8sgpt-operator description: A Helm chart for Kubernetes +maintainers: + - name: "The K8sGPT Authors" + email: "noreply@k8sgpt.ai" + url: https://github.com/k8sgpt-ai/community + # A chart can be either an 'application' or a 'library' chart. # # Application charts are a collection of templates that can be packaged into versioned archives @@ -13,7 +18,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.0.6 #x-release-please-version +version: 0.0.6 # x-release-please-version # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. diff --git a/chart/templates/_helpers.tpl b/chart/operator/templates/_helpers.tpl similarity index 100% rename from chart/templates/_helpers.tpl rename to chart/operator/templates/_helpers.tpl diff --git a/chart/templates/controller-manager-metrics-monitor.yaml b/chart/operator/templates/controller-manager-metrics-monitor.yaml similarity index 100% rename from chart/templates/controller-manager-metrics-monitor.yaml rename to chart/operator/templates/controller-manager-metrics-monitor.yaml diff --git a/chart/templates/deployment.yaml b/chart/operator/templates/deployment.yaml similarity index 100% rename from chart/templates/deployment.yaml rename to chart/operator/templates/deployment.yaml diff --git a/chart/templates/k8sgpt-crd.yaml b/chart/operator/templates/k8sgpt-crd.yaml similarity index 100% rename from chart/templates/k8sgpt-crd.yaml rename to chart/operator/templates/k8sgpt-crd.yaml diff --git a/chart/templates/leader-election-rbac.yaml b/chart/operator/templates/leader-election-rbac.yaml similarity index 100% rename from chart/templates/leader-election-rbac.yaml rename to chart/operator/templates/leader-election-rbac.yaml diff --git a/chart/templates/manager-rbac.yaml b/chart/operator/templates/manager-rbac.yaml similarity index 100% rename from chart/templates/manager-rbac.yaml rename to chart/operator/templates/manager-rbac.yaml diff --git a/chart/templates/metrics-reader-rbac.yaml b/chart/operator/templates/metrics-reader-rbac.yaml similarity index 100% rename from chart/templates/metrics-reader-rbac.yaml rename to chart/operator/templates/metrics-reader-rbac.yaml diff --git a/chart/templates/metrics-service.yaml b/chart/operator/templates/metrics-service.yaml similarity index 85% rename from chart/templates/metrics-service.yaml rename to chart/operator/templates/metrics-service.yaml index ca352f8e..7ddb9daf 100644 --- a/chart/templates/metrics-service.yaml +++ b/chart/operator/templates/metrics-service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "chart.fullname" . }}-controller-manager-metrics-service + name: {{ include "chart.fullname" . | trunc 20}}-controller-manager-metrics-service labels: app.kubernetes.io/component: kube-rbac-proxy app.kubernetes.io/created-by: k8sgpt-operator diff --git a/chart/templates/proxy-rbac.yaml b/chart/operator/templates/proxy-rbac.yaml similarity index 100% rename from chart/templates/proxy-rbac.yaml rename to chart/operator/templates/proxy-rbac.yaml diff --git a/chart/templates/result-crd.yaml b/chart/operator/templates/result-crd.yaml similarity index 100% rename from chart/templates/result-crd.yaml rename to chart/operator/templates/result-crd.yaml diff --git a/chart/values.yaml b/chart/operator/values.yaml similarity index 100% rename from chart/values.yaml rename to chart/operator/values.yaml