From 0c85e0494653c08e9867a2a18a30433c9fc6ed6f 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, 11 Jun 2021 19:56:14 +0200 Subject: [PATCH] [meta] Auto-generate docs (#974) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs --- .../workflows/charts-auto-generate-docs.yaml | 91 +++++++++++++++++++ .github/workflows/charts-lint-test.yaml | 4 + .github/workflows/pre-commit-check.yaml | 4 + 3 files changed, 99 insertions(+) create mode 100644 .github/workflows/charts-auto-generate-docs.yaml diff --git a/.github/workflows/charts-auto-generate-docs.yaml b/.github/workflows/charts-auto-generate-docs.yaml new file mode 100644 index 00000000..8d54839b --- /dev/null +++ b/.github/workflows/charts-auto-generate-docs.yaml @@ -0,0 +1,91 @@ +name: "Charts: Auto-generate docs" + +on: + workflow_dispatch: + pull_request: + paths: + - 'charts/**/Chart.yaml' + - 'charts/**/values.yaml' + - 'charts/**/*.md.gotmpl' + - 'charts/**/README.md' + +concurrency: + group: ${{ github.head_ref }}-generate-docs + cancel-in-progress: true + +jobs: + generate-readme: + if: "!contains(github.event.head_commit.message, '[ci-skip]') && github.actor != 'k8s-at-home[bot]'" + name: Auto-generate chart README + runs-on: ubuntu-20.04 + steps: + - name: Get k8s-at-home token + id: get-app-token + uses: getsentry/action-github-app-token@v1 + with: + app_id: ${{ secrets.K8S_AT_HOME_APP_ID }} + private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }} + + - name: Checkout + uses: actions/checkout@v2 + with: + token: ${{ steps.get-app-token.outputs.token }} + ref: ${{ github.ref }} + fetch-depth: 0 + + - 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: Update Pull Request + 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/**/ diff --git a/.github/workflows/charts-lint-test.yaml b/.github/workflows/charts-lint-test.yaml index e26a8ddd..c85ff6c1 100644 --- a/.github/workflows/charts-lint-test.yaml +++ b/.github/workflows/charts-lint-test.yaml @@ -9,6 +9,10 @@ on: - '!charts/**/README_CHANGELOG.md.gotmpl' - '!charts/**/README_CONFIG.md.gotmpl' +concurrency: + group: ${{ github.head_ref }}-lint + cancel-in-progress: true + jobs: changes-lint: if: "!contains(github.event.head_commit.message, '[ci-skip]')" diff --git a/.github/workflows/pre-commit-check.yaml b/.github/workflows/pre-commit-check.yaml index 60412146..8cfe3afe 100644 --- a/.github/workflows/pre-commit-check.yaml +++ b/.github/workflows/pre-commit-check.yaml @@ -4,6 +4,10 @@ on: workflow_dispatch: pull_request: +concurrency: + group: ${{ github.head_ref }}-precommit + cancel-in-progress: true + jobs: pre-commit-check: if: "!contains(github.event.head_commit.message, '[ci-skip]')"