Skip to content

Commit 66fb8d3

Browse files
committed
github: modify github action to trigger whenever a commit is made to property-overrides
1 parent be83200 commit 66fb8d3

File tree

1 file changed

+64
-15
lines changed

1 file changed

+64
-15
lines changed

.github/workflows/update-property-docs.yaml

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
type: string
1111
repository_dispatch:
1212
types: [trigger-property-docs-generation]
13+
push:
14+
paths: ['docs-data/property-overrides.json']
1315

1416
jobs:
1517
generate-property-docs:
@@ -36,7 +38,7 @@ jobs:
3638
- name: Checkout the repository
3739
uses: actions/checkout@v4
3840
with:
39-
ref: main
41+
ref: ${{ github.event_name == 'push' && github.ref || 'main' }}
4042
token: ${{ env.ACTIONS_BOT_TOKEN }}
4143

4244
- name: Set up Node.js
@@ -54,32 +56,62 @@ jobs:
5456
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
5557
elif [ -n "${{ github.event.client_payload.tag }}" ]; then
5658
echo "tag=${{ github.event.client_payload.tag }}" >> $GITHUB_OUTPUT
59+
elif [ "${{ github.event_name }}" = "push" ]; then
60+
# For push events, use the current latest-redpanda-tag from antora.yml
61+
CURRENT=$(grep 'latest-redpanda-tag:' antora.yml | awk '{print $2}' | tr -d "\"'")
62+
echo "tag=$CURRENT" >> $GITHUB_OUTPUT
63+
echo "🔄 Using current latest-redpanda-tag for override changes: $CURRENT"
5764
else
5865
echo "❌ No tag provided via input or dispatch payload" >&2
5966
exit 1
6067
fi
6168
62-
- name: Check if tag is newer than antora.yml latest
69+
- name: Check if docs need regeneration
6370
id: version_check
71+
env:
72+
GH_TOKEN: ${{ env.ACTIONS_BOT_TOKEN }}
6473
run: |
6574
set -euo pipefail
6675
TAG="${{ steps.tag.outputs.tag }}"
6776
CURRENT=$(grep 'latest-redpanda-tag:' antora.yml | awk '{print $2}' | tr -d "\"'")
6877
6978
echo "📄 Current latest-redpanda-tag in antora.yml: $CURRENT"
70-
echo "🔖 Incoming tag: $TAG"
71-
72-
# Strip leading 'v' for numeric comparison
73-
CUR_NUM=$(echo "$CURRENT" | sed 's/^v//')
74-
NEW_NUM=$(echo "$TAG" | sed 's/^v//')
79+
echo "🔖 Using tag: $TAG"
7580
76-
# Compare semver using sort -V
77-
if [ "$(printf "%s\n%s" "$CUR_NUM" "$NEW_NUM" | sort -V | tail -n1)" = "$NEW_NUM" ] && [ "$CUR_NUM" != "$NEW_NUM" ]; then
78-
echo "$TAG is newer than $CURRENT"
79-
echo "is_newer=true" >> $GITHUB_OUTPUT
81+
# For push events (override file changes), check if generated docs are up to date
82+
if [ "${{ github.event_name }}" = "push" ]; then
83+
echo "🔄 Override file changed — checking if generated docs need update"
84+
85+
# Check if generated property docs exist and are newer than the override file
86+
OVERRIDE_FILE="docs-data/property-overrides.json"
87+
GENERATED_FILE="modules/reference/pages/properties/broker-properties.adoc"
88+
89+
if [ -f "$GENERATED_FILE" ]; then
90+
# Compare file modification times
91+
if [ "$OVERRIDE_FILE" -nt "$GENERATED_FILE" ]; then
92+
echo "🔄 Override file is newer than generated docs — regeneration needed"
93+
echo "is_newer=true" >> $GITHUB_OUTPUT
94+
else
95+
echo "✅ Generated docs are up to date with override file — skipping"
96+
echo "is_newer=false" >> $GITHUB_OUTPUT
97+
fi
98+
else
99+
echo "🔄 Generated docs don't exist — regeneration needed"
100+
echo "is_newer=true" >> $GITHUB_OUTPUT
101+
fi
80102
else
81-
echo "$TAG is not newer than $CURRENT — skipping doc generation"
82-
echo "is_newer=false" >> $GITHUB_OUTPUT
103+
# Strip leading 'v' for numeric comparison
104+
CUR_NUM=$(echo "$CURRENT" | sed 's/^v//')
105+
NEW_NUM=$(echo "$TAG" | sed 's/^v//')
106+
107+
# Compare semver using sort -V
108+
if [ "$(printf "%s\n%s" "$CUR_NUM" "$NEW_NUM" | sort -V | tail -n1)" = "$NEW_NUM" ] && [ "$CUR_NUM" != "$NEW_NUM" ]; then
109+
echo "$TAG is newer than $CURRENT"
110+
echo "is_newer=true" >> $GITHUB_OUTPUT
111+
else
112+
echo "$TAG is not newer than $CURRENT — skipping doc generation"
113+
echo "is_newer=false" >> $GITHUB_OUTPUT
114+
fi
83115
fi
84116
85117
- name: Generate property docs
@@ -95,13 +127,30 @@ jobs:
95127
env:
96128
GITHUB_TOKEN: ${{ env.ACTIONS_BOT_TOKEN }}
97129

130+
- name: Commit generated docs to current branch
131+
if: steps.version_check.outputs.is_newer == 'true' && github.event_name == 'push'
132+
run: |
133+
git config --local user.email "[email protected]"
134+
git config --local user.name "vbotbuildovich"
135+
136+
# Add generated files
137+
git add modules/reference/pages/properties/ modules/reference/partials/properties/
138+
139+
# Check if there are changes to commit
140+
if git diff --staged --quiet; then
141+
echo "No changes to commit"
142+
else
143+
git commit -m "auto-docs: Regenerate property docs after override changes"
144+
git push origin HEAD
145+
fi
146+
98147
- name: Create pull request
99-
if: steps.version_check.outputs.is_newer == 'true'
148+
if: steps.version_check.outputs.is_newer == 'true' && github.event_name != 'push'
100149
uses: peter-evans/create-pull-request@v6
101150
with:
102151
token: ${{ env.ACTIONS_BOT_TOKEN }}
103152
commit-message: "auto-docs: Update property docs for ${{ steps.tag.outputs.tag }}"
104-
branch: update-property-docs-${{ steps.tag.outputs.tag }}
153+
branch: "update-property-docs-${{ steps.tag.outputs.tag }}"
105154
title: "auto-docs: Update property docs for tag ${{ steps.tag.outputs.tag }}"
106155
body: |
107156
This PR auto-generates updated Redpanda property documentation for **${{ steps.tag.outputs.tag }}**.

0 commit comments

Comments
 (0)