From 7a8a14bde860dcba08d71976337fd70b0fd54dd6 Mon Sep 17 00:00:00 2001 From: jklein Date: Thu, 19 Feb 2026 14:26:17 +0100 Subject: [PATCH] feat(publish-workflow): added general publish-workflow --- .github/workflows/publish-helm-chart.yml | 87 ++++++++++++++++++++++++ .gitignore | 8 +++ 2 files changed, 95 insertions(+) create mode 100644 .github/workflows/publish-helm-chart.yml create mode 100644 .gitignore diff --git a/.github/workflows/publish-helm-chart.yml b/.github/workflows/publish-helm-chart.yml new file mode 100644 index 0000000..5bf3ab9 --- /dev/null +++ b/.github/workflows/publish-helm-chart.yml @@ -0,0 +1,87 @@ +name: Publish Helm Chart with patched Application Version +on: + workflow_dispatch: + inputs: + app-version: + required: false + type: string + description: "change the version of the underlying application" + chart-location: + required: false + type: string + default: "." + description: "location of the helm chart directory" + chart-name: + required: true + type: string + description: "name of the helm chart" + workflow_call: + inputs: + app-version: + required: true + type: string + description: "change the version of the underlying application" + chart-location: + required: false + type: string + default: "." + description: "location of the helm chart directory" + chart-name: + required: true + type: string + description: "name of the helm chart" + secrets: + OP_CONNECT_TOKEN: + required: true +jobs: + publish-helm-chart: + runs-on: ubuntu-latest + steps: + - name: "Checkout Repository" + uses: actions/checkout@v2 + - name: "Install Helm" + uses: azure/setup-helm@v4 + - name: "Configure OP-Connect" + uses: 1password/load-secrets-action/configure@v2 + with: + connect-host: https://op-connect.jk-dev.de + - name: "Get Chart Version" + if: inputs.app-version != '' + run: | + CHART_VERSION=$(grep '^version:' ${{ inputs.chart-name}}/Chart.yaml | awk '{print $2}') + CHART_PART=$(echo $CHART_VERSION | cut -d'-' -f1) + echo "CHART_VERSION=$CHART_PART" >> $GITHUB_ENV + working-directory: ${{ inputs.chart-location }} + - name: "Get new Chart Version" + if: inputs.app-version != '' + run: | + APP_VERSION_NORMALIZED=$(echo "${{ inputs.app-version }}" | tr '.' '-') + NEW_VERSION="${CHART_VERSION}-release-${APP_VERSION_NORMALIZED}" + sed -i "s/^version:.*/version: $NEW_VERSION/" ${{ inputs.chart-name }}/Chart.yaml + sed -i "s/^appVersion:.*/appVersion: ${{ inputs.app-version }}/" ${{ inputs.chart-name }}/Chart.yaml + working-directory: ${{ inputs.chart-location }} + - name: "Package Helm Chart" + run: helm package ${{ inputs.chart-name }} + working-directory: ${{ inputs.chart-location }} + - name: "View directory contents" + run: ls -al + working-directory: ${{ inputs.chart-location }} + - name: "View helm-chart-meta contents" + run: cat Chart.yaml + working-directory: ${{ inputs.chart-location }}/${{ inputs.chart-name }} + - name: "Load Helm Registry Credentials" + id: load-jk-cr-creds + uses: 1password/load-secrets-action@v2 + env: + OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }} + JK_CR_TOKEN: op://GitHub-Actions/jk-registry-access/password + JK_CR_USERNAME: op://GitHub-Actions/jk-registry-access/username + JK_CR_CHARTS_LOCATION: op://GitHub-Actions/jk-registry-access/charts-location + JK_CR_HELM_REGISTRY: op://GitHub-Actions/jk-registry-access/helm-registry + - name: "Login to JK-Registry" + run: echo ${{ env.JK_CR_TOKEN }} | helm registry login ${{ env.JK_CR_HELM_REGISTRY }} -u ${{ env.JK_CR_USERNAME }} --password-stdin + - name: "Push Helm Chart to JK-Container Registry" + run: helm push ${{ inputs.chart-name }}-*.tgz ${{ env.JK_CR_CHARTS_LOCATION }} + working-directory: ${{ inputs.chart-location }} + - name: "Logout from JK-Registry" + run: helm registry logout cr.jk-dev.de \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f27a85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +### Example user template template +### Example user template + +# IntelliJ project files +.idea +*.iml +out +gen