-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (97 loc) · 3.6 KB
/
Copy pathdocs.yml
File metadata and controls
108 lines (97 loc) · 3.6 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Update Documentation
on:
push:
branches:
- main
paths:
- 'charts/**/values.yaml'
- 'charts/**/Chart.yaml'
- 'charts/**/README.md.gotmpl'
- 'README.md.gotmpl'
workflow_dispatch:
jobs:
update-docs:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- name: Prepare environment
run: |
mkdir -p ~/.local/bin
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Cache binaries
id: cache-tools
uses: actions/cache@v4
with:
path: |
~/.local/bin/gomplate
~/.local/bin/helm-docs
~/.local/bin/yq
key: ${{ runner.os }}-docs-tools-202603
- name: Install binaries
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
TEMP_DIR=$(mktemp -d)
cd $TEMP_DIR
curl -sSfL https://github.com/hairyhenderson/gomplate/releases/download/v5.0.0/gomplate_linux-amd64 -o ~/.local/bin/gomplate
curl -sSfL https://github.com/norwoodj/helm-docs/releases/download/v1.14.2/helm-docs_1.14.2_Linux_x86_64.tar.gz -o helm-docs.tar.gz
tar -xzf helm-docs.tar.gz helm-docs
mv helm-docs ~/.local/bin/helm-docs
curl -sSfL https://github.com/mikefarah/yq/releases/download/v4.45.1/yq_linux_amd64 -o ~/.local/bin/yq
chmod +x ~/.local/bin/gomplate ~/.local/bin/helm-docs ~/.local/bin/yq
cd -
rm -rf $TEMP_DIR
- name: Install tools
run: |
sudo apt-get update && sudo apt-get install -y gettext-base jq
- name: Configure environment
run: |
REPO_OWNER="${GITHUB_REPOSITORY_OWNER:-${GITHUB_REPOSITORY%%/*}}"
REPO_NAME="${GITHUB_REPOSITORY##*/}"
echo "REPO_URL=https://${REPO_OWNER}.github.io/${REPO_NAME}" >> $GITHUB_ENV
- name: Prepare charts data
run: |
shopt -s nullglob
rm -f /tmp/charts-list.jsonl
for f in charts/*/Chart.yaml; do
yq -o=json '.' "$f" | jq -c '{name: .name, description: .description, version: .version}' >> /tmp/charts-list.jsonl
done
jq -s '{charts: .}' /tmp/charts-list.jsonl > /tmp/charts-data.json
shopt -u nullglob
- name: Update chart READMEs
env:
REPO_URL: ${{ env.REPO_URL }}
run: |
shopt -s nullglob
for tmpl in charts/*/README.md.gotmpl; do
dir=$(dirname "$tmpl")
REPO_URL="${REPO_URL}" envsubst '${REPO_URL}' < "$tmpl" > "${dir}/README.md.gotmpl.tmp"
helm-docs \
--chart-search-root="${dir}" \
--template-files="$(realpath ${dir}/README.md.gotmpl.tmp)" \
--output-file="README.md" \
--ignore-non-descriptions \
--log-level=warn
rm -f "${dir}/README.md.gotmpl.tmp"
done
shopt -u nullglob
- name: Update root README
env:
REPO_URL: ${{ env.REPO_URL }}
run: |
gomplate -f README.md.gotmpl -o README.md -d charts=file:///tmp/charts-data.json
- name: Commit and push changes
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add README.md charts/*/README.md
if ! git diff --cached --quiet; then
git commit -m "docs: update generated documentation [skip ci]"
git push origin main
else
echo "No documentation changes to commit."
fi