feat(helm)!: Update Chart homarr (5.13.0 → 6.0.0) #3794
This file contains hidden or 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
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| --- | |
| name: Helm Dynamic Rendered Manifest | |
| on: | |
| merge_group: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| rendered-manifest: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Generate Token | |
| uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 | |
| id: app-token | |
| with: | |
| app-id: ${{ secrets.GHAPP_APP_ID }} | |
| private-key: ${{ secrets.GHAPP_PRIVATE_KEY }} | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| token: '${{ steps.app-token.outputs.token }}' | |
| fetch-depth: 0 | |
| - name: Find modified Chart.yaml files | |
| id: changed-files | |
| uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46 | |
| with: | |
| files: | | |
| **/Chart.yaml | |
| **/Chart.yml | |
| **/*values.yaml | |
| **/*values.yml | |
| - name: Generate diffs for each Chart | |
| id: gen-pr-chart | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| env: | |
| ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
| VALUES_FILE: values-full.yaml | |
| run: | | |
| set +e | |
| RED="\033[1;31m" | |
| GREEN="\033[1;32m" | |
| YELLOW="\033[1;33m" | |
| BLUE="\033[1;34m" | |
| PURPLE="\033[1;35m" | |
| CYAN="\033[1;36m" | |
| BLANK="\033[0m" | |
| echo "CHART_FILES=${ALL_CHANGED_FILES}" | |
| UNIQ_PATHS_CHANGED=$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | grep -v '^$' | awk -F/ '{if (NF > 1) {NF--; print $0}}' OFS='/' | sort -u) | |
| echo "UNIQ_PATHS_CHANGED=$UNIQ_PATHS_CHANGED" | |
| get_latest_version() { | |
| local repo=$1 | |
| local chart=$2 | |
| local pattern=$3 | |
| helm search repo "$repo/$chart" --versions | awk 'NR>1 {print $2}' | sed 's/^v//' | grep -E "^${pattern//./\\.}" | sort -V | tail -n1 | |
| } | |
| template_version() { | |
| local suffix=$1 | |
| mkdir -p $suffix | |
| CHART_NAME=$(yq e '.name' "$path/Chart.yaml") | |
| CHART_VERSION=$(yq e '.version' "$path/Chart.yaml") | |
| echo -e "${CYAN}[ INFO ] > Directory --> ${PURPLE}${path}${BLANK}" | |
| echo -e "${CYAN}[ INFO ] > Chart name --> ${PURPLE}${CHART_NAME}${BLANK}" | |
| echo -e "${CYAN}[ INFO ] > Chart version --> ${PURPLE}${CHART_VERSION}${BLANK}" | |
| for dep in $(yq e -o=j -I=0 '.dependencies[]' "$path/Chart.yaml") | |
| do | |
| echo "$dep" | jq -C | |
| DEP_NAME=$(echo "$dep" | jq -r '.name') | |
| DEP_VERSION=$(echo "$dep" | jq -r '.version') | |
| DEP_REPO=$(echo "$dep" | jq -r '.repository') | |
| if [[ "$DEP_REPO" =~ ^oci:// ]] | |
| then | |
| echo -e "${CYAN}[ INFO ] > OCI chart detected for ${PURPLE}${DEP_NAME}${CYAN} with repository ${PURPLE}${DEP_REPO}${CYAN}${BLANK}" | |
| OCI_CHART="${DEP_REPO}/${DEP_NAME}" | |
| helm pull "$OCI_CHART" --version "$DEP_VERSION" --untar --untardir "$suffix/oci_temp" | |
| echo -e "${CYAN}[ INFO ] > Extracted OCI chart to $suffix/oci_temp${BLANK}" | |
| else | |
| echo -e "${CYAN}[ INFO ] > Adding dependency ${PURPLE}${DEP_NAME}${CYAN} with repo ${PURPLE}${DEP_REPO}${CYAN}${BLANK}" | |
| helm repo add "$DEP_NAME" "$DEP_REPO" --force-update | |
| helm repo update "$DEP_NAME" | |
| fi | |
| done | |
| helm dependency update "$path" --skip-refresh | |
| if [ ! -f "${path}/${VALUES_FILE}" ] | |
| then | |
| VALUES_FILE=$(find "$path" -maxdepth 1 -type f -name '*values*.yaml' | head -n 1 | awk -F '/' '{print $NF}') | |
| if [ ! -f "${path}/${VALUES_FILE}" ] | |
| then | |
| echo -e "${RED}[ ERROR ] > No values.yaml file found" | |
| else | |
| echo -e "${CYAN}[ INFO ] > Specific values.yaml file found : ${PURPLE}${path}/${VALUES_FILE}${BLANK}" | |
| fi | |
| else | |
| echo -e "${CYAN}[ INFO ] > Detected default values file: ${PURPLE}${path}/${VALUES_FILE}${BLANK}" | |
| fi | |
| echo -e "${YELLOW}[ EXECUTING ] > Rendering for branch : ${GREEN}${suffix}${BLANK}" | |
| echo -e "${YELLOW}[ EXECUTING ] > Generating template for ${GREEN}${CHART_NAME}${YELLOW} version ${GREEN}${CHART_VERSION}${YELLOW} with values file ${GREEN}${path}/${VALUES_FILE}${YELLOW} to file ${GREEN}${suffix}/${CHART_NAME}_${path//\//_}_manifest_${suffix}.yaml${BLANK}" | |
| if [ -f "$(dirname ${path})/values/common-values.yaml" ] | |
| then | |
| echo -e "${CYAN}[ INFO ] > Common values.yaml file found : ${PURPLE}$(dirname ${path})/values/common-values.yaml${BLANK}" | |
| helm template "$CHART_NAME" "$path" -f "$(dirname ${path})/values/common-values.yaml" -f ${path}/${VALUES_FILE} > "${suffix}/${CHART_NAME}_${path//\//_}_manifest_${suffix}.yaml" | |
| else | |
| echo -e "${CYAN}[ INFO ] > No common values.yaml${BLANK}" | |
| helm template "$CHART_NAME" "$path" -f ${path}/${VALUES_FILE} > "${suffix}/${CHART_NAME}_${path//\//_}_manifest_${suffix}.yaml" | |
| fi | |
| if [ -d "$suffix/oci_temp" ] | |
| then | |
| rm -rf "$suffix/oci_temp" | |
| echo -e "${CYAN}[ INFO ] > Cleaned up temporary OCI chart directory${BLANK}" | |
| fi | |
| echo "" | |
| } | |
| for path in ${UNIQ_PATHS_CHANGED} | |
| do | |
| echo -e "${BLUE}[ STEP ] > Processing path ${YELLOW}${path}${BLANK}" | |
| if [ ! -f "${path}/Chart.yaml" ] | |
| then | |
| if [ -f "${path}/common-values.yaml" ] | |
| then | |
| echo -e "${CYAN}[ INFO ] > common-values.yaml has been modified, processing diff for all charts${BLANK}" | |
| for dir in $(find "$(dirname ${path})" -mindepth 1 -maxdepth 1 -type d | grep -v '/values$') | |
| do | |
| echo -e "${CYAN}[ INFO ] > Env ${PURPLE}$(basename ${dir})${BLANK}" | |
| old_path=${path} | |
| path=${dir} | |
| template_version "pr" | |
| git checkout origin/main -- "$(dirname ${old_path})" | |
| template_version "main" | |
| git checkout origin/${{ github.head_ref }} -- "$(dirname ${old_path})" | |
| done | |
| else | |
| echo -e "${RED}[ ERROR ] > No helm chart found" | |
| exit 1 | |
| fi | |
| else | |
| template_version "pr" | |
| git checkout origin/main -- "$path" | |
| template_version "main" | |
| git checkout origin/${{ github.head_ref }} -- "$path" | |
| fi | |
| done | |
| - name: Generate dyff on release | |
| id: dyff-helm | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| uses: ixxeL-DevOps/gha-templates/.github/actions/dyff@main | |
| with: | |
| source: main/*_manifest_main.yaml | |
| target: pr/*_manifest_pr.yaml | |
| exclude-regexp: spec.template.metadata.annotations.checksum | |
| - name: Generate diff on release | |
| id: diff-helm | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| uses: ixxeL-DevOps/gha-templates/.github/actions/diff@main | |
| with: | |
| source: main/*_manifest_main.yaml | |
| target: pr/*_manifest_pr.yaml | |
| - name: Post diff as comment | |
| if: steps.changed-files.outputs.any_changed == 'true' && github.event_name == 'pull_request' | |
| run: | | |
| gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body-file diff.md --edit-last || \ | |
| gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body-file diff.md | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.TOKEN }} | |
| - name: Kubeconform | |
| id: kubeconform | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| continue-on-error: true | |
| uses: ixxeL-DevOps/gha-templates/.github/actions/kubeconform@main | |
| with: | |
| target: pr |