-
Notifications
You must be signed in to change notification settings - Fork 9
53 lines (45 loc) · 1.85 KB
/
generate-chart-readme.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: 'Update README metadata'
on:
pull_request:
branches:
- main
paths:
- "charts/**"
permissions: {} # Remove all permissions by default
jobs:
update-readme-metadata:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Install readme-generator-for-helm
run: npm install -g @bitnami/readme-generator-for-helm
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Necessary for getting a complete history for diffs
- name: Get modified charts
id: get-modified-charts
run: |
paths=$(git diff --name-only origin/main... --name-only | grep 'charts/.*/values.yaml' | cut -d/ -f1,2 | uniq | tr '\n' ' ')
echo "Modified charts: $paths"
echo "paths=${paths}" >> $GITHUB_ENV # Using ENV as this is now within the same job
- name: Execute readme-generator-for-helm
if: env.paths != '' # Ensure there are paths to proceed
run: |
IFS=' ' read -ra ADDR <<< "$paths"
echo "Updating READMEs for modified charts: ${ADDR[@]}"
for chart in "${ADDR[@]}"; do
echo "Updating README.md for ${chart}"
readme-generator --values "${chart}/values.yaml" --readme "${chart}/README.md"
if [[ $? -ne 0 ]]; then
echo "Error: Failed to update README for ${chart}"
exit 1
fi
# fix schema for nullable
# cat <<< $(jq '(..|objects|select(.nullable)).type |= ["string","null"]' "${chart}/values.schema.json") > "${chart}/values.schema.json"
done
- name: Commit and Push Changes
if: env.paths != '' # Only commit if there are changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update README and values.schema.json for modified charts