From ffa47f512f75b89242de23ab0bb70cb8a7d01d79 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: Sat, 12 Jun 2021 15:21:15 +0200 Subject: [PATCH] [CI] Update CI --- .../workflows/charts-auto-generate-docs.yaml | 72 ++++++++++++++++--- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/.github/workflows/charts-auto-generate-docs.yaml b/.github/workflows/charts-auto-generate-docs.yaml index 0d68eb3c..698b3a99 100644 --- a/.github/workflows/charts-auto-generate-docs.yaml +++ b/.github/workflows/charts-auto-generate-docs.yaml @@ -103,15 +103,69 @@ jobs: generate-readme-fork: if: github.event_name == 'repository_dispatch' -# github.event_name == 'repository_dispatch' && -# github.event.client_payload.slash_command.sha != '' && -# contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.sha) name: Auto-generate chart README runs-on: ubuntu-20.04 steps: - # # Check out merge commit - # - name: Fork based /ok-to-test checkout - # uses: actions/checkout@v2 - # with: - # ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge' - - uses: hmarr/debug-action@v2 + # Check out merge commit + - name: Fork based /ok-to-test checkout + uses: actions/checkout@v2 + with: + ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge' + + - uses: dorny/paths-filter@v2 + id: filter + with: + list-files: shell + filters: | + addedOrModified: + - added|modified: 'charts/**' + + - name: Install Helm + if: steps.filter.outputs.addedOrModified == 'true' + uses: azure/setup-helm@v1 + with: + version: v3.5.3 + + - uses: actions/setup-python@v2 + if: steps.filter.outputs.addedOrModified == 'true' + with: + python-version: 3.7 + + - name: Install helm-docs + if: steps.filter.outputs.addedOrModified == 'true' + run: | + wget -O /tmp/helm-docs.deb https://github.com/norwoodj/helm-docs/releases/download/v1.5.0/helm-docs_1.5.0_linux_amd64.deb + sudo dpkg -i /tmp/helm-docs.deb + + - name: Run against changed charts + if: steps.filter.outputs.addedOrModified == 'true' + run: | + CHARTS=() + PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) + # Get only the chart paths + for i in "${PATHS[@]}" + do + IFS='/' read -r -a path_parts <<< "$i" + CHARTS+=("${path_parts[1]}/${path_parts[2]}") + done + + # Remove duplicates + CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` ) + + for i in "${CHARTS[@]}" + do + echo "Rendering README for chart ${i}" + IFS='/' read -r -a chart_parts <<< "$i" + ./hack/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}" + echo "" + done + + - name: Create commit + if: steps.filter.outputs.addedOrModified == 'true' + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Auto-generate chart README + commit_user_name: k8s-at-home[bot] + commit_user_email: + commit_author: k8s-at-home[bot] + file_pattern: charts/**/