From d14c607713d2c65b3480144b73f4818bcdf5c8d4 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Sun, 10 Aug 2025 11:07:17 +0200 Subject: [PATCH] Add GitHub workflow for building Keycloak Helm chart This commit introduces a new workflow file for building the Helm chart for Keycloak in the Gitea CI/CD pipeline. The workflow is triggered on push events to the main branch specifically when changes are made to the "charts/keycloak/Chart.yaml" file. The workflow includes several steps: - **Checkout the repository**: It pulls the latest code. - **Set Helm Chart App Name and Version**: It extracts the app name and version from the Chart.yaml file, allowing the Helm package to be named correctly. - **Setup Helm**: It installs Helm version 3.18.3 for packaging purposes. - **Package Helm Chart**: It updates dependencies, lints the chart, and packages it into a tgz file. - **Upload Helm Package**: It uploads the newly created Helm chart package to the specified Helm registry using credentials stored in Gitea secrets. This addition is necessary to automate the process of building and deploying the Helm chart, ensuring consistency and efficiency in the CI/CD pipeline. --- .gitea/workflows/build-chart-keycloak.yml | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .gitea/workflows/build-chart-keycloak.yml diff --git a/.gitea/workflows/build-chart-keycloak.yml b/.gitea/workflows/build-chart-keycloak.yml new file mode 100644 index 0000000..e5ddf02 --- /dev/null +++ b/.gitea/workflows/build-chart-keycloak.yml @@ -0,0 +1,43 @@ +name: "Build Helm Chart" +on: + push: + branches: + - main + paths: + - "charts/keycloak/Chart.yaml" + +jobs: + helm-package: + runs-on: ubuntu-latest + env: + APP: charts/keycloak + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set Helm Chart App Name and Version + id: get_version + run: | + APP_NAME=$(grep -oP '(?<=^name: ).*' ${{ env.APP }}/Chart.yaml) + echo "Helm Chart App Name: $APP_NAME" + echo "::set-output name=app::$APP_NAME" + + CHART_VERSION=$(grep -oP '(?<=^version: ).*' ${{ env.APP }}/Chart.yaml) + echo "Helm Chart version: $CHART_VERSION" + echo "::set-output name=tag::$CHART_VERSION" + + - name: Setup Helm + run: | + #curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash + curl -kSso /usr/local/bin/helm https://debmirror.cooltux.net/helm-v3.18.3 && chmod +x /usr/local/bin/helm + helm version + + - name: Package Helm Chart + run: | + helm dependency update ${{ env.APP }} + helm lint ${{ env.APP }} + helm package ${{ env.APP }} + + - name: Upload Helm Package to repo + run: | + curl --user ${{ secrets.USER }}:${{ secrets.TOKEN }} -X POST --upload-file ./${{ steps.get_version.outputs.app }}-${{ steps.get_version.outputs.tag }}.tgz ${{ vars.HELMREGISTRY }}/api/packages/${{ vars.OWNER }}/helm/api/charts