From bbb81ffb9e129edc704c6085ede0d7c3b404524a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Fri, 4 Feb 2022 14:31:20 +0100 Subject: [PATCH] ci: Update chart release flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs --- .github/workflows/charts-release.yaml | 85 +++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 5 deletions(-) diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 4808daaa..281d4359 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -26,6 +26,86 @@ jobs: with: token: ${{ steps.generate-token.outputs.token }} ref: master + + - name: Install Kubernetes tools + uses: yokawasa/action-setup-kube-tools@v0.8.0 + with: + setup-tools: | + helmv3 + yq + helm: 3.6.3 + yq: "4.16.2" + + - name: Install helm-docs + run: | + wget -O /tmp/helm-docs.deb https://github.com/k8s-at-home/helm-docs/releases/download/v0.1.1/helm-docs_0.1.1_Linux_x86_64.deb + sudo dpkg -i /tmp/helm-docs.deb + + - name: Collect changed files + uses: dorny/paths-filter@v2 + id: filter + with: + list-files: shell + filters: | + addedOrModified: + - added|modified: 'charts/**' + + - name: Collect changed charts + if: | + steps.filter.outputs.addedOrModified == 'true' + id: filter-charts + run: | + CHARTS=() + PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) + # Get only the chart paths + for CHARTPATH in "${PATHS[@]}" + do + IFS='/' read -r -a path_parts <<< "${CHARTPATH}" + CHARTS+=("${path_parts[1]}/${path_parts[2]}") + done + + # Remove duplicates + CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` ) + # Set output to changed charts + printf "::set-output name=addedOrModified::%s\n" "${CHARTS[*]}" + + - name: Generate README for changed charts in Renovate PR's + if: | + steps.filter.outputs.addedOrModified == 'true' + run: | + CHARTS=(${{ steps.filter-charts.outputs.addedOrModified }}) + for i in "${CHARTS[@]}" + do + IFS='/' read -r -a chart_parts <<< "$i" + if [ -f "charts/${chart_parts[0]}"/"${chart_parts[1]}/Chart.yaml" ]; then + ./.github/scripts/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}" + fi + done + + - name: Create commit + id: create-commit + uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: charts/**/ + commit_message: Auto-update chart README [ci-skip] + commit_user_name: k8s-at-home[bot] + commit_user_email: k8s-at-home[bot]@users.noreply.github.com + commit_author: k8s-at-home[bot] + + - name: Store commit hash + id: store-commit-hash + run: | + if [ "${{ steps.create-commit.outputs.changes_detected || 'unknown' }}" == "true" ]; then + echo '::set-output name=commit_hash::${{ steps.create-commit.outputs.commit_hash }}' + else + echo "::set-output name=commit_hash::${GITHUB_SHA}" + fi + + - name: Checkout + uses: actions/checkout@v2 + with: + token: ${{ steps.generate-token.outputs.token }} + ref: ${{ steps.store-commit-hash.outputs.commit_hash }} fetch-depth: 0 - name: Configure Git @@ -33,11 +113,6 @@ jobs: git config user.name "k8s-at-home[bot]" git config user.email "k8s-at-home[bot]@users.noreply.github.com" - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: v3.6.3 - - name: Run chart-releaser uses: helm/chart-releaser-action@v1.2.1 with: