From b4af8c56c19dfbf8379c81444d3a5f829351e63c 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: Thu, 3 Feb 2022 16:44:15 +0100 Subject: [PATCH] ci: Expand PR workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs --- .github/workflows/charts-update-readme.yaml | 84 +++++++++++++++++++++ .github/workflows/pr-validate.yaml | 8 ++ 2 files changed, 92 insertions(+) create mode 100644 .github/workflows/charts-update-readme.yaml diff --git a/.github/workflows/charts-update-readme.yaml b/.github/workflows/charts-update-readme.yaml new file mode 100644 index 00000000..706da5cc --- /dev/null +++ b/.github/workflows/charts-update-readme.yaml @@ -0,0 +1,84 @@ +name: "Charts: Update README" + +on: + workflow_call: + inputs: + modifiedCharts: + required: true + type: string + isRenovatePR: + required: true + type: string + outputs: + commitHash: + description: "The commit hash to use in later jobs" + value: ${{ jobs.generate-readme.outputs.commitHash }} + +jobs: + generate-readme: + name: Generate chart README files + runs-on: ubuntu-latest + outputs: + commitHash: ${{ steps.store-commit-hash.outputs.commit_hash }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Kubernetes tools + uses: yokawasa/action-setup-kube-tools@v0.8.0 + with: + setup-tools: | + yq + 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: Annotate Charts.yaml for Renovate PR's + # run: | + # export DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}') + # CHARTS=(${{ inputs.modifiedCharts }}) + # for i in "${CHARTS[@]}" + # do + # IFS='/' read -r -a chart_parts <<< "$i" + # if [ -f "charts/${chart_parts[0]}"/"${chart_parts[1]}/Chart.yaml" ]; then + # ./hack/renovate-releasenotes.sh "charts/${chart_parts[0]}"/"${chart_parts[1]}" + # fi + # echo "" + # done + + - name: Generate README for changed charts + run: | + CHARTS=(${{ inputs.modifiedCharts }}) + for i in "${CHARTS[@]}" + do + printf "Rendering README for chart %s\n" "${i}" + echo " ${i}" + IFS='/' read -r -a chart_parts <<< "$i" + if [ -f "charts/${chart_parts[0]}"/"${chart_parts[1]}/Chart.yaml" ]; then + ./hack/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}" + fi + echo "" + done + + - name: Create commit + id: create-commit + uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: charts/**/ + commit_message: Auto-update chart metadata and README + commit_user_name: ${{ github.actor }} + commit_user_email: ${{ github.actor }}@users.noreply.github.com + + - name: Store commit hash + id: store-commit-hash + run: | + if [ "${{ steps.create-commit.outputs.changes_detected }}" == "true"]; then + echo '::set-output name=commit_hash::${{ steps.create-commit.outputs.commit_hash }}' + else + echo "::set-output name=commit_hash::${GITHUB_SHA}" + fi diff --git a/.github/workflows/pr-validate.yaml b/.github/workflows/pr-validate.yaml index 2e4232a8..b27a393c 100644 --- a/.github/workflows/pr-validate.yaml +++ b/.github/workflows/pr-validate.yaml @@ -12,3 +12,11 @@ concurrency: jobs: pr-get-metadata: uses: k8s-at-home/charts/.github/workflows/pr-get-metadata.yaml@master + + charts-update-readme: + uses: k8s-at-home/charts/.github/workflows/charts-update-readme.yaml@master + needs: + - pr-get-metadata + with: + isRenovatePR: ${{ needs.pr-get-metadata.outputs.isRenovatePR }} + modifiedCharts: ${{ needs.pr-get-metadata.outputs.addedOrModifiedCharts }}