1- ---
2- name : Generate CRD Reference Docs
1+ name : Generate Kubernetes Reference Docs
32on :
4- workflow_dispatch : # Allows manual trigger of the workflow
5- repository_dispatch : # Allows other repositories to trigger this workflow
3+ workflow_dispatch :
4+ inputs :
5+ tag :
6+ description : ' The Operator release tag for which to generate the docs'
7+ required : true
8+ repository_dispatch :
69 types : [generate-crd-docs]
710jobs :
811 trigger :
@@ -11,40 +14,123 @@ jobs:
1114 id-token : write
1215 contents : read
1316 steps :
17+ - name : Determine operator tag
18+ id : set_operator_tag
19+ shell : bash
20+ run : |
21+ if [ -n "${{ github.event.inputs.tag }}" ]; then
22+ TAG="${{ github.event.inputs.tag }}"
23+ else
24+ TAG="${{ github.event.release.tag_name }}"
25+ fi
26+ # Check if the tag has the expected prefix.
27+ if [[ "$TAG" =~ ^operator/ ]]; then
28+ echo "OPERATOR_TAG=$TAG" >> $GITHUB_ENV
29+ else
30+ echo "Tag does not have the operator/ prefix. Skipping workflow."
31+ exit 0
32+ fi
33+
34+ # Configure AWS credentials to get the secret for the Redpanda GitHub bot.
1435 - uses : aws-actions/configure-aws-credentials@v4
1536 with :
1637 aws-region : ${{ vars.RP_AWS_CRED_REGION }}
1738 role-to-assume : arn:aws:iam::${{ secrets.RP_AWS_CRED_ACCOUNT_ID }}:role/${{ vars.RP_AWS_CRED_BASE_ROLE_NAME }}${{ github.event.repository.name }}
39+
1840 - uses : aws-actions/aws-secretsmanager-get-secrets@v2
1941 with :
2042 secret-ids : |
2143 ,sdlc/prod/github/actions_bot_token
2244 parse-json-secrets : true
23- # Checkout the specified branch from redpanda repository.
24- - name : Checkout redpanda repository
45+
46+ - name : Get latest docs version
47+ id : antora_version
48+ shell : bash
49+ run : |
50+ ANTORA_VERSION=$(curl -s https://raw.githubusercontent.com/redpanda-data/docs/main/antora.yml | grep '^version:' | sed -E 's/version: *//')
51+ echo "Latest docs version is: $ANTORA_VERSION"
52+ echo "ANTORA_VERSION=$ANTORA_VERSION" >> $GITHUB_ENV
53+
54+ - name : Determine docs branch
55+ id : set_docs_branch
56+ shell : bash
57+ run : |
58+ TAG="${OPERATOR_TAG}"
59+ echo "Original operator tag: $TAG"
60+
61+ # Filter the tag to include only the vmajor.minor version.
62+ # This will remove any "operator/" prefix and any patch version information.
63+ FILTERED_TAG=$(echo "$TAG" | sed -E 's/^(operator\/)?(v[0-9]+\.[0-9]+).*/\2/')
64+ echo "Filtered tag (vmajor.minor): $FILTERED_TAG"
65+
66+ if [[ "$FILTERED_TAG" == "v2.4" ]]; then
67+ echo "Filtered tag is v2.4. Checking docs version."
68+ if [[ "$ANTORA_VERSION" == "25.1" ]]; then
69+ echo "Docs main branch version is 25.1, using docs branch 'main'."
70+ DOCS_BRANCH="main"
71+ else
72+ echo "Using docs branch v/24.3 for filtered tag v2.4."
73+ if git ls-remote --exit-code --heads https://github.com/redpanda-data/docs.git refs/heads/v/24.3; then
74+ DOCS_BRANCH="v/24.3"
75+ else
76+ echo "Docs branch v/24.3 not found. Skipping."
77+ exit 0
78+ fi
79+ fi
80+ else
81+ echo "Filtered tag is: $FILTERED_TAG"
82+ # For other tags, if the filtered tag matches the latest docs version, then use the main branch.
83+ if [[ "$FILTERED_TAG" == "v${ANTORA_VERSION}" ]]; then
84+ DOCS_BRANCH="main"
85+ else
86+ # Otherwise, derive the docs branch from the filtered tag.
87+ DOCS_BRANCH="v/${FILTERED_TAG#v}"
88+ if ! git ls-remote --exit-code --heads https://github.com/redpanda-data/docs.git refs/heads/"$DOCS_BRANCH"; then
89+ echo "Docs branch $DOCS_BRANCH not found."
90+ exit 0
91+ fi
92+ fi
93+ fi
94+ echo "DOCS_BRANCH=$DOCS_BRANCH" >> $GITHUB_ENV
95+ echo "Using docs branch: $DOCS_BRANCH"
96+
97+ # Checkout the operator repository at the specified tag.
98+ - name : Checkout redpanda operator repository
2599 uses : actions/checkout@v4
26100 with :
27101 repository : redpanda-data/redpanda-operator
28- ref : main
102+ ref : ${{ env.OPERATOR_TAG }}
29103 path : redpanda
30104 token : ${{ env.ACTIONS_BOT_TOKEN }}
31- # Checkout the redpanda-docs repository based on the FORMATTED_BRANCH.
32- - name : Checkout this repository
105+
106+ # Checkout the docs repository using the determined docs branch.
107+ - name : Checkout redpanda-docs repository
33108 uses : actions/checkout@v4
34109 with :
35- ref : main
36110 repository : redpanda-data/docs
111+ ref : ${{ env.DOCS_BRANCH }}
37112 path : redpanda-docs
38113 token : ${{ env.ACTIONS_BOT_TOKEN }}
39- # Download crd-ref-docs utility for doc generation.
114+
40115 - name : Download crd-ref-docs
41116 run : |
42117 curl -fLO https://github.com/elastic/crd-ref-docs/releases/download/v0.1.0/crd-ref-docs_0.1.0_Linux_x86_64.tar.gz
43118 tar -xzf crd-ref-docs_0.1.0_Linux_x86_64.tar.gz
44119 chmod +x crd-ref-docs
45120 sudo mv crd-ref-docs /usr/local/bin/
46- # Generate Operator CRD documentation.
47- - name : Generate Operator CRD Docs
121+
122+ - name : Download helm-docs
123+ run : |
124+ curl -sL https://github.com/norwoodj/helm-docs/releases/download/v1.11.0/helm-docs_1.11.0_Linux_x86_64.tar.gz | tar xz
125+ echo "helm-docs" >> $GITHUB_PATH
126+ sudo mv helm-docs /usr/local/bin/
127+
128+ # Install pandoc, a tool to convert between different markup formats.
129+ - name : Install pandoc
130+ run : |
131+ sudo apt-get install pandoc
132+
133+ - name : Generate Operator CRD docs
48134 run : |
49135 crd-ref-docs \
50136 --source-path=./redpanda/operator/api/redpanda/v1alpha2 \
@@ -53,26 +139,47 @@ jobs:
53139 --config=./redpanda/operator/crd-ref-docs-config.yaml \
54140 --renderer=asciidoctor \
55141 --output-path=./redpanda-docs/modules/reference/pages/k-crd.adoc
56- # Check for any changes made in the documentation.
57- - name : Check if changes were made
58- id : check_changes
142+
143+ - name : Generate Helm docs
59144 run : |
60- cd ./redpanda -docs
61- changes=$(git status --porcelain)
62- if [ -z "$changes" ]; then
63- echo "has_changes=false" >> $GITHUB_ENV
64- else
65- echo "has_changes=true" >> $GITHUB_ENV
66- fi
67- # If changes were detected, commit those changes.
68- - name : Commit changes
69- if : env.has_changes == 'true'
145+ helm -docs
146+ working-directory : ./redpanda
147+
148+ # Convert the generated Markdown Helm documentation to AsciiDoc format using pandoc.
149+ - name : Convert Markdown to AsciiDoc
150+ run : |
151+ pandoc ./helm-charts/charts/redpanda/README.md -t asciidoc -o ./redpanda-docs/modules/reference/pages/k-redpanda-helm-spec.adoc
152+ pandoc ./helm-charts/charts/console/README.md -t asciidoc -o ./redpanda-docs/modules/reference/pages/k-console-helm-spec.adoc
153+ pandoc ./helm-charts/charts/operator/README.md -t asciidoc -o ./redpanda-docs/modules/reference/pages/k-operator-helm-spec.adoc
154+ - name : Modify third-level headings format
70155 run : |
71- cd ./redpanda-docs
72- git config --global user.email "[email protected] " 73- git config --global user.name "vbotbuildovich"
74- git add .
75- git commit -m "auto-docs: Update CRD reference doc"
76- git push origin main
77- env :
78- ACCESS_TOKEN : ${{ env.ACTIONS_BOT_TOKEN }}
156+ sed -i 's/\(\[[0-9]*\)\]\./\1\\]\./g' ./redpanda-docs/modules/reference/pages/k-redpanda-helm-spec.adoc
157+ sed -i 's/\(\[[0-9]*\)\]\./\1\\]\./g' ./redpanda-docs/modules/reference/pages/k-console-helm-spec.adoc
158+ sed -i 's/\(\[[0-9]*\)\]\]/\1\\]\]/g' ./redpanda-docs/modules/reference/pages/k-operator-helm-spec.adoc
159+ sed -i 's/=== \(http\([^[]\|\%5[BbDd]\)*\)\[\([^]]*\)\]/=== link:++\1++\[\3\]/' ./redpanda-docs/modules/reference/pages/k-redpanda-helm-spec.adoc
160+ sed -i 's/=== \(http\([^[]\|\%5[BbDd]\)*\)\[\([^]]*\)\]/=== link:++\1++\[\3\]/' ./redpanda-docs/modules/reference/pages/k-console-helm-spec.adoc
161+ sed -i 's/=== \(http\([^[]\|\%5[BbDd]\)*\)\[\([^]]*\)\]/=== link:++\1++\[\3\]/' ./redpanda-docs/modules/reference/pages/k-operator-helm-spec.adoc
162+ - name : Correct AsciiDoc format
163+ run : |
164+ # Correct the title format
165+ sed -i 's/^== # \(.*\)/= \1/' ./redpanda-docs/modules/reference/pages/k-redpanda-helm-spec.adoc
166+ sed -i 's/^== # \(.*\)/= \1/' ./redpanda-docs/modules/reference/pages/k-console-helm-spec.adoc
167+ sed -i 's/^== # \(.*\)/= \1/' ./redpanda-docs/modules/reference/pages/k-operator-helm-spec.adoc
168+ # Correct the description format
169+ sed -i 's/^== description: \(.*\)/:description: \1/' ./redpanda-docs/modules/reference/pages/k-redpanda-helm-spec.adoc
170+ sed -i 's/^== description: \(.*\)/:description: \1/' ./redpanda-docs/modules/reference/pages/k-console-helm-spec.adoc
171+ sed -i 's/^== description: \(.*\)/:description: \1/' ./redpanda-docs/modules/reference/pages/k-operator-helm-spec.adoc
172+
173+ # If changes were detected, open a pull request against the determined docs branch.
174+ - name : Create pull request
175+ uses : peter-evans/create-pull-request@v6
176+ with :
177+ commit-message : " auto-docs: Update CRD reference doc for release ${{ env.OPERATOR_TAG }}"
178+ token : ${{ env.ACTIONS_BOT_TOKEN }}
179+ path : redpanda-docs
180+ branch : auto-docs/update-${{ env.OPERATOR_TAG }}
181+ base : ${{ env.DOCS_BRANCH }}
182+ title : " auto-docs: Update CRD reference doc for release ${{ env.OPERATOR_TAG }}"
183+ body : |
184+ This PR updates the CRD reference documentation for operator release ${{ env.OPERATOR_TAG }}.
185+ labels : auto-docs
0 commit comments